Cons[A: A]¶
A list with a head and a tail, where the tail can be empty.
Implements¶
- ReadSeq[val->A] box
Constructors¶
create¶
Parameters¶
Returns¶
- Cons[A] val^
Public Functions¶
size¶
Returns the size of the list.
Returns¶
- USize val
apply¶
Returns the i-th element of the list. Errors if the index is out of bounds.
Parameters¶
- i: USize val
Returns¶
- val->A ?
values¶
Returns an iterator over the elements of the list.
Returns¶
- Iterator[val->A] ref^
is_empty¶
Returns a Bool indicating if the list is empty.
Returns¶
- Bool val
is_non_empty¶
Returns a Bool indicating if the list is non-empty.
Returns¶
- Bool val
head¶
Returns the head of the list.
Returns¶
- val->A
tail¶
Returns the tail of the list.
Returns¶
reverse¶
Builds a new list by reversing the elements in the list.
Returns¶
prepend¶
Builds a new list with an element added to the front of this list.
Parameters¶
- a: val->A!
Returns¶
- Cons[A] val
concat¶
Builds a new list that is the concatenation of this list and the provided list.
Parameters¶
Returns¶
map[B: B]¶
Builds a new list by applying a function to every member of the list.
Parameters¶
- f: {(val->A): val->B}[A, B] box
Returns¶
flat_map[B: B]¶
Builds a new list by applying a function to every member of the list and using the elements of the resulting lists.
Parameters¶
- f: {(val->A): List[B]}[A, B] box
Returns¶
for_each¶
Applies the supplied function to every element of the list in order.
Parameters¶
- f: {(val->A)}[A] box
Returns¶
- None val
filter¶
Builds a new list with those elements that satisfy a provided predicate.
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
fold[B: B]¶
Folds the elements of the list using the supplied function.
Parameters¶
- f: {(B, val->A): B^}[A, B] box
- acc: B
Returns¶
- B
every¶
Returns true if every element satisfies the provided predicate, false otherwise.
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Bool val
exists¶
Returns true if at least one element satisfies the provided predicate, false otherwise.
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Bool val
partition¶
Builds a pair of lists, the first of which is made up of the elements satisfying the supplied predicate and the second of which is made up of those that do not.
fun val partition(
f: {(val->A): Bool}[A] box)
: ((Cons[A] val | Nil[A] val) , (Cons[A] val | Nil[A] val))
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
drop¶
Builds a list by dropping the first n elements.
Parameters¶
- n: USize val
Returns¶
drop_while¶
Builds a list by dropping elements from the front of the list until one fails to satisfy the provided predicate.
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
take¶
Builds a list of the first n elements.
Parameters¶
- n: USize val
Returns¶
take_while¶
Builds a list of elements satisfying the provided predicate until one does not.
Parameters¶
- f: {(val->A): Bool}[A] box