A standard linked list
list
append
- Appends one list to anothereach
- Iterate over a listfind
- Search for an element that matches a given predicatefoldl
- Left foldfrom_vec
- Create a list from a vectorhas
- Returns true if a list contains an element with the given valuehead
- Returns the first element of a listis_empty
- Returns true if the list is emptyis_not_empty
- Returns true if the list is not emptyiter
- Iterate over a listlen
- Returns the length of a listpush
- Push an element to the front of a listtail
- Returns all but the first element of a listlist
cons(T, @list<T>)
nil
append
pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T>
Appends one list to another
each
fn each<T>(l: @list<T>, f: fn(T) -> bool)
Iterate over a list
find
fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T>
Search for an element that matches a given predicate
Apply function f
to each element of v
, starting from the first. When function f
returns true then an option containing the element is returned. If f
matches no elements then none is returned.
foldl
fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T
Left fold
Applies f
to u
and the first element in the list, then applies f
to the result of the previous call and the second element, and so on, returning the accumulated result.
from_vec
fn from_vec<T: copy>(v: & [T]) -> @list<T>
Create a list from a vector
has
fn has<T: copy>(ls: @list<T>, elt: T) -> bool
Returns true if a list contains an element with the given value
head
pure fn head<T: copy>(ls: @list<T>) -> T
Returns the first element of a list
is_empty
pure fn is_empty<T: copy>(ls: @list<T>) -> bool
Returns true if the list is empty
is_not_empty
pure fn is_not_empty<T: copy>(ls: @list<T>) -> bool
Returns true if the list is not empty
iter
fn iter<T>(l: @list<T>, f: fn(T))
Iterate over a list
len
fn len<T>(ls: @list<T>) -> uint
Returns the length of a list
push
fn push<T: copy>(&l: list<T>, v: T)
Push an element to the front of a list
tail
pure fn tail<T: copy>(ls: @list<T>) -> @list<T>
Returns all but the first element of a list