Permalink
Browse files

Simplify zip/2 function.

Tail call recursion + lists:reverse/1 is no longer fastest on all
platforms.
  • Loading branch information...
1 parent 622eda2 commit 8ecc03a8e0b60184e89f42dc9ae4aa6fdebd1a42 @pichi pichi committed Nov 27, 2013
Showing with 3 additions and 9 deletions.
  1. +3 −9 src/proper_statem.erl
View
@@ -741,15 +741,9 @@ state_env_after(Mod, Cmds) ->
%% useful for zipping a command sequence with its (failing) execution history.
-spec zip([A], [B]) -> [{A,B}].
-zip(X, Y) ->
- zip(X, Y, []).
-
--spec zip([A], [B], [{A,B}]) -> [{A,B}].
-zip([], _, Accum) -> lists:reverse(Accum);
-zip(_, [], Accum) -> lists:reverse(Accum);
-zip([X|Tail1], [Y|Tail2], Accum) ->
- zip(Tail1, Tail2, [{X,Y}|Accum]).
-
+zip([A|X], [B|Y]) -> [{A,B}|zip(X, Y)];
+zip(_, []) -> [];
+zip([], _) -> [].
%% -----------------------------------------------------------------------------
%% Utility functions

0 comments on commit 8ecc03a

Please sign in to comment.