tags:

views:

113

answers:

1
+3  Q: 

'zip' in Erlang

I'm just wondering if there is a ready implementation of zip-function in the standart erlang library. Something like that:

zip([H1|T1], [H2|T2], Acc)->
    zip(T1, T2, Acc ++ [{H1, H2}]);
zip([], [], Acc) ->
    Acc.
+9  A: 

There is a zip function in the lists module:

> lists:zip([a,b,c], [1,2,3]).
[{a,1},{b,2},{c,3}]
Martinho Fernandes