Module lists

An implementation of the Erlang/OTP lists interface.

Description

This module implements a strict susbset of the Erlang/OTP lists interface.

Function Index

all/2 Evaluates to true iff Fun(E) =:= true, for all E in List.
any/2 Evaluates to true iff Fun(E) =:= true, for some E in List.
delete/2 Remove E from L.
duplicate/2 Duplicate an element.
filter/2 Filter a list by a predicate, returning the list of elements for which the predicate is true.
flatten/1 recursively flattens elements of L into a single list.
foldl/3 Fold over a list of terms, from left to right, applying Fun(E, Accum) to each successive element in List.
foldr/3 Fold over a list of terms, from right to left, applying Fun(E, Accum) to each successive element in List.
foreach/2 Applies given fun to each list element.
join/2 Inserts Sep between every element of List.
keydelete/3 Delete the entry in L whose Ith element matches K.
keyfind/3 Find the entry in L whose Ith element matches K.
keymember/3 Returns true if a Ith element matches K.
keyreplace/4 Returns the result of replacing NewTuple for the first element in L with who's Ith element matches K.
map/2 Map a list of terms, applying Fun(E).
member/2 Determine whether a term is a member of a list.
nth/2 Get the value in a list at position N.
reverse/1 Reverse the elements of L.
search/2 If there is a Value in List such that Pred(Value) returns true, returns {value, Value} for the first such Value, otherwise returns false.
seq/2 Returns a sequence of integers in a specified range.
seq/3 Returns a sequence of integers in a specified range incremented by a specified value.
sort/1 Returns a sorted list, using < operator to determine sort order.
sort/2 Returns a sorted list, using Fun(A, B) to determine sort order.
sublist/2 Return a sublist made of the first Len elements of List.

Function Details

all/2


all(Fun::fun((Elem::term()) -> boolean()), List::list()) -> boolean()

Fun: the predicate to evaluate
List: the list over which to evaluate elements

returns: true if Fun(E) evaluates to true, for all elements in List

Evaluates to true iff Fun(E) =:= true, for all E in List

any/2


any(Fun::fun((Elem::term()) -> boolean()), List::list()) -> boolean()

Fun: the predicate to evaluate
List: the list over which to evaluate elements

returns: true if Fun(E) evaluates to true, for at least one in List

Evaluates to true iff Fun(E) =:= true, for some E in List

delete/2


delete(E::term(), L::list()) -> Result::list()

E: the member to delete
L: the list from which to delete the value

returns: the result of removing E from L, if it exists in L; otherwise, L.

Remove E from L

duplicate/2


duplicate(Count::integer(), Elem) -> [Elem]

Count: the number of times to duplicate the element
Elem: the element to duplicate

returns: a list made of Elem duplicate Count times

Duplicate an element

filter/2


filter(Pred::fun((Elem::term()) -> boolean()), List::list()) -> list()

Pred: the predicate to apply to elements in List
List: list

returns: all values in L for which Pred is true.

Filter a list by a predicate, returning the list of elements for which the predicate is true.

flatten/1


flatten(L::list()) -> list()

L: the list to flatten

returns: flattened list

recursively flattens elements of L into a single list

foldl/3


foldl(Fun::fun((Elem::term(), AccIn::term()) -> AccOut::term()), Acc0::term(), List::list()) -> Acc1::term()

Fun: the function to apply
List: the list over which to fold

returns: the result of folding Fun over L

Fold over a list of terms, from left to right, applying Fun(E, Accum) to each successive element in List

foldr/3


foldr(Fun::fun((Elem::term(), AccIn::term()) -> AccOut::term()), Acc0::term(), List::list()) -> Acc1::term()

Equivalent to foldl(Fun, Acc0, reverse(List)).

Fold over a list of terms, from right to left, applying Fun(E, Accum) to each successive element in List

foreach/2


foreach(Fun::fun((Elem::term()) -> term()), List::list()) -> ok

Fun: the predicate to evaluate
List: the list over which to evaluate elements

returns: ok

Applies given fun to each list element

join/2


join(Sep::list(), List::list()) -> list()

Sep: the separator
List: list

returns: the result of inserting Sep between every element of List.

Inserts Sep between every element of List.

keydelete/3


keydelete(K::term(), I::pos_integer(), L::list()) -> list()

K: the key to match
I: the position in the tuple to compare (1..tuple_size)
L: the list from which to delete the element

returns: the result of deleting any element in L who’s Ith element matches K

Delete the entry in L whose Ith element matches K.

keyfind/3


keyfind(K::term(), I::pos_integer(), L::[tuple()]) -> tuple() | false

K: the key to match
I: the position in the tuple to compare (1..tuple_size)
L: the list from which to find the element

returns: the tuple in L who’s Ith element matches K; the atom false, otherwise

Find the entry in L whose Ith element matches K.

keymember/3


keymember(K::term(), I::pos_integer(), L::[tuple()]) -> boolean()

K: the key to match
I: the position in the tuple to compare (1..tuple_size)
L: the list from which to find the element

returns: true if there is a tuple in L who’s Ith element matches K; the atom false, otherwise

Returns true if a Ith element matches K.

keyreplace/4


keyreplace(K::term(), I::pos_integer(), L::[tuple()], NewTuple::{NewKey::term(), Val::term()}) -> boolean()

K: the key to match
I: the position in the tuple to compare (1..tuple_size)
L: the list from which to find the element
NewTuple: tuple containing the new key to replace param K

returns: result of replacing the first element in L who’s Ith element matches K with the contents of NewTuple.

Returns the result of replacing NewTuple for the first element in L with who’s Ith element matches K.

map/2


map(Fun::fun((Elem::term()) -> Out::term()), List::list()) -> OutList::term()

Fun: the function to apply
List: the list over which to map

returns: the result of mapping over L

Map a list of terms, applying Fun(E)

member/2


member(E::term(), L::list()) -> boolean()

E: the member to search for
L: the list from which to get the value

returns: true if E is a member of L; false, otherwise.

Determine whether a term is a member of a list.

nth/2


nth(N::non_neg_integer(), L::list()) -> term()

N: the index in the list to get
L: the list from which to get the value

returns: the value in the list at position N.

Get the value in a list at position N.

Returns the value at the specified position in the list. The behavior of this function is undefined if N is outside of the {1..length(L)}.

reverse/1


reverse(L::list()) -> list()

L: the list to reverse

returns: the elements of L in reverse order

Reverse the elements of L.

search/2


search(Pred::fun((Elem::term()) -> boolean()), List::list()) -> {value, Value::term()} | false

Pred: the predicate to apply to elements in List
List: search

returns: the first {value, Val}, if Pred(Val); false, otherwise.

If there is a Value in List such that Pred(Value) returns true, returns {value, Value} for the first such Value, otherwise returns false.

seq/2


seq(From::integer(), To::integer()) -> list()

From: from integer
To: to Integer

returns: list of integers from [From..To]

Returns a sequence of integers in a specified range.

This function is equivalent to lists:seq(From, To, 1).

seq/3

seq(From, To, Incr) -> any()

Returns a sequence of integers in a specified range incremented by a specified value.

sort/1

sort(List) -> any()

Returns a sorted list, using < operator to determine sort order.

sort/2

sort(Fun, List) -> any()

Returns a sorted list, using Fun(A, B) to determine sort order.

sublist/2


sublist(List::[Elem], Len::integer()) -> [Elem]

List: list to take the sublist from
Len: the number of elements to get from List

returns: a list made of the first Len elements of List

Return a sublist made of the first Len elements of List. It is not an error for Len to be larger than the length of List.