aboutsummaryrefslogtreecommitdiff
path: root/gen/src
diff options
context:
space:
mode:
authorRobert Peterson <robert.peterson@gmail.com>2019-04-16 17:00:25 -0700
committerLouis Pilfold <louis@lpil.uk>2019-04-17 16:12:57 +0100
commit6ae1f2cf51868e2bd05ae47ec1cf09344dc1393b (patch)
tree57dc58419990cc6219be353f6f0b758024112ff2 /gen/src
parent933dc2c4b723ad45d96a7bfc6fb0fb4651550d05 (diff)
downloadgleam_stdlib-6ae1f2cf51868e2bd05ae47ec1cf09344dc1393b.tar.gz
gleam_stdlib-6ae1f2cf51868e2bd05ae47ec1cf09344dc1393b.zip
Add list:zip
Diffstat (limited to 'gen/src')
-rw-r--r--gen/src/list.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/gen/src/list.erl b/gen/src/list.erl
index 97c0579..39a30a3 100644
--- a/gen/src/list.erl
+++ b/gen/src/list.erl
@@ -1,7 +1,7 @@
-module(list).
-compile(no_auto_import).
--export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, traverse/2, drop/2, take/2, new/0, append/2, flatten/1, fold/3, fold_right/3, find/2, all/2, any/2]).
+-export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, traverse/2, drop/2, take/2, new/0, append/2, flatten/1, fold/3, fold_right/3, find/2, all/2, any/2, zip/2]).
length(A) ->
erlang:length(A).
@@ -201,3 +201,15 @@ any(List, F) ->
true
end
end.
+
+zip(L1, L2) ->
+ case {L1, L2} of
+ {[], _} ->
+ [];
+
+ {_, []} ->
+ [];
+
+ {[X1 | Rest1], [X2 | Rest2]} ->
+ [{X1, X2} | zip(Rest1, Rest2)]
+ end.