lists:zip / zip_with / unzip etc
Fri Jul 5 08:34:23 CEST 2002
The zip function is indeed missing in the lists module,
like the uniq function (removing duplicates from a list).
> ziph([H1|L1],[H2|L2], Z) ->
> ziph(,L2, Z) ->
> ziph(L1,, Z) ->
> zip(A,B) ->
This solution for zip has complexity 2N (2 times the length
of the list). It is easy to make a solution that only
traverses the list once.
It is a matter of taste whether you accept lists of
unequal length. I would like the program to crash (in the
Erlang style) if you offer it two lists of unequal length.
More information about the erlang-questions