aboutsummaryrefslogtreecommitdiff
path: root/gen/src
diff options
context:
space:
mode:
authorAlice Dee <alice.dee@guardian.co.uk>2019-09-17 12:45:44 +0100
committerLouis Pilfold <louis@lpil.uk>2019-09-17 12:59:32 +0100
commit01a691b6e7df1834b1f75e07617a209770c48fbf (patch)
tree58a8e99dd313d975c38dbd24effe1f381c326858 /gen/src
parent198beba763f8bc0fd35b5b6ba36e42c5926ecc8c (diff)
downloadgleam_stdlib-01a691b6e7df1834b1f75e07617a209770c48fbf.tar.gz
gleam_stdlib-01a691b6e7df1834b1f75e07617a209770c48fbf.zip
Move fetch to list module as key_find
Diffstat (limited to 'gen/src')
-rw-r--r--gen/src/gleam@list.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/gen/src/gleam@list.erl b/gen/src/gleam@list.erl
index 7781dcc..e8eabd2 100644
--- a/gen/src/gleam@list.erl
+++ b/gen/src/gleam@list.erl
@@ -1,7 +1,7 @@
-module(gleam@list).
-compile(no_auto_import).
--export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, index_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, strict_zip/2, intersperse/2, at/2, unique/1, sort/2, range/2, repeat/2, split/2, split_while/2]).
+-export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, index_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, strict_zip/2, intersperse/2, at/2, unique/1, sort/2, range/2, repeat/2, split/2, split_while/2, key_find/2]).
length(A) ->
erlang:length(A).
@@ -373,3 +373,12 @@ do_split_while(List, F, Acc) ->
split_while(List, F) ->
do_split_while(List, F, []).
+
+key_find(Haystack, Needle) ->
+ find(Haystack, fun(P) -> case gleam@pair:first(P) =:= Needle of
+ true ->
+ {ok, gleam@pair:second(P)};
+
+ false ->
+ {error, nil}
+ end end).