aboutsummaryrefslogtreecommitdiff
path: root/gen/src/gleam@list.erl
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-10-21 19:10:08 +0100
committerLouis Pilfold <louis@lpil.uk>2019-10-25 15:13:33 +0100
commit74519318c70297b4e90b83011d353e40577f4e90 (patch)
treec6408c61d027f5b99b3f17266257332481885930 /gen/src/gleam@list.erl
parent1fd3d745cf6baa4cbaf3469f963f17fa6f5420cd (diff)
downloadgleam_stdlib-74519318c70297b4e90b83011d353e40577f4e90.tar.gz
gleam_stdlib-74519318c70297b4e90b83011d353e40577f4e90.zip
stdlib labelled parameters
Diffstat (limited to 'gen/src/gleam@list.erl')
-rw-r--r--gen/src/gleam@list.erl50
1 files changed, 25 insertions, 25 deletions
diff --git a/gen/src/gleam@list.erl b/gen/src/gleam@list.erl
index 4e3a60d..508da27 100644
--- a/gen/src/gleam@list.erl
+++ b/gen/src/gleam@list.erl
@@ -55,8 +55,8 @@ do_filter(List, Fun, Acc) ->
do_filter(Xs, Fun, NewAcc)
end.
-filter(List, Fun) ->
- do_filter(List, Fun, []).
+filter(List, Predicate) ->
+ do_filter(List, Predicate, []).
do_map(List, Fun, Acc) ->
case List of
@@ -151,63 +151,63 @@ do_flatten(Lists, Acc) ->
flatten(Lists) ->
do_flatten(Lists, []).
-fold(List, Acc, Fun) ->
+fold(List, Initial, Fun) ->
case List of
[] ->
- Acc;
+ Initial;
[X | Rest] ->
- fold(Rest, Fun(X, Acc), Fun)
+ fold(Rest, Fun(X, Initial), Fun)
end.
-fold_right(List, Acc, Fun) ->
+fold_right(List, Initial, Fun) ->
case List of
[] ->
- Acc;
+ Initial;
[X | Rest] ->
- Fun(X, fold_right(Rest, Acc, Fun))
+ Fun(X, fold_right(Rest, Initial, Fun))
end.
-find(Haystack, F) ->
+find(Haystack, Predicate) ->
case Haystack of
[] ->
{error, nil};
[X | Rest] ->
- case F(X) of
+ case Predicate(X) of
{ok, X1} ->
{ok, X1};
_ ->
- find(Rest, F)
+ find(Rest, Predicate)
end
end.
-all(List, F) ->
+all(List, Predicate) ->
case List of
[] ->
true;
[X | Rest] ->
- case F(X) of
+ case Predicate(X) of
true ->
- all(Rest, F);
+ all(Rest, Predicate);
_ ->
false
end
end.
-any(List, F) ->
+any(List, Predicate) ->
case List of
[] ->
false;
[X | Rest] ->
- case F(X) of
+ case Predicate(X) of
false ->
- any(Rest, F);
+ any(Rest, Predicate);
_ ->
true
@@ -247,8 +247,8 @@ intersperse(List, Elem) ->
[X1, Elem | intersperse(Rest, Elem)]
end.
-at(List, I) ->
- case I < 0 of
+at(List, Index) ->
+ case Index < 0 of
true ->
{error, nil};
@@ -258,12 +258,12 @@ at(List, I) ->
{error, nil};
[X | Rest] ->
- case I =:= 0 of
+ case Index =:= 0 of
true ->
{ok, X};
false ->
- at(Rest, I - 1)
+ at(Rest, Index - 1)
end
end
end.
@@ -353,8 +353,8 @@ do_split(List, N, Taken) ->
end
end.
-split(List, N) ->
- do_split(List, N, []).
+split(List, Target) ->
+ do_split(List, Target, []).
do_split_while(List, F, Acc) ->
case List of
@@ -371,8 +371,8 @@ do_split_while(List, F, Acc) ->
end
end.
-split_while(List, F) ->
- do_split_while(List, F, []).
+split_while(List, Predicate) ->
+ do_split_while(List, Predicate, []).
key_find(Haystack, Needle) ->
find(Haystack, fun(P) -> case gleam@pair:first(P) =:= Needle of