erlang list

list syntax is same to list in python.


favourite functions in lists module.

nth(N, List).

sublist(List1, Len)/sublist(List, start, len).

sort(List).

usort(fun, List).

seq(From, To , [Incr]) is same to range() in python.

append(list of lists).

append(List1 , List2), same to ++ 

map/filter/zip/unzip is same to the cressponding in python.

flatten(DeepList) -> a new flatten list.

foldl(Fun, Acc0, List) is just the reduce funtion.

for example:

lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1, 2, 3]).

foldr like foldl, but the list is traversed from right to left.

keyfind(Key, PositionOfKeyInTuple, ListOfTuple)

for example:

->lists:keyfind(name, 1, [{name, 'gh'}, {name, 'ss'}]).

->{name, 'gh'}

keydelete(Key, N, TupleList) -> TupleList1


partition(fun, List) -> {satisfyingList, NonSatisfyingList}.

你可能感兴趣的:(list,erlang,fun)