Nil[A: A]¶
The empty list of As.
primitive val Nil[A: A] is
ReadSeq[val->A] box
Implements¶
- ReadSeq[val->A] box
Constructors¶
create¶
new val create()
: Nil[A] val^
Returns¶
- Nil[A] val^
Public Functions¶
size¶
Returns the size of the list.
fun box size()
: USize val
Returns¶
- USize val
apply¶
Returns the i-th element of the sequence. For the empty list this call will always error because any index will be out of bounds.
fun box apply(
i: USize val)
: val->A ?
Parameters¶
- i: USize val
Returns¶
- val->A ?
values¶
Returns an empty iterator over the elements of the empty list.
fun box values()
: Iterator[val->A] ref^
Returns¶
- Iterator[val->A] ref^
is_empty¶
Returns a Bool indicating if the list is empty.
fun box is_empty()
: Bool val
Returns¶
- Bool val
is_non_empty¶
Returns a Bool indicating if the list is non-empty.
fun box is_non_empty()
: Bool val
Returns¶
- Bool val
head¶
Returns an error, since Nil has no head.
fun box head()
: val->A ?
Returns¶
- val->A ?
tail¶
Returns an error, since Nil has no tail.
fun box tail()
: (Cons[A] val | Nil[A] val) ?
Returns¶
reverse¶
The reverse of the empty list is the empty list.
fun box reverse()
: Nil[A] val
Returns¶
- Nil[A] val
prepend¶
Builds a new list with an element added to the front of this list.
fun box prepend(
a: val->A!)
: Cons[A] val
Parameters¶
- a: val->A!
Returns¶
- Cons[A] val
concat¶
The concatenation of any list l with the empty list is l.
fun box concat(
l: (Cons[A] val | Nil[A] val))
: (Cons[A] val | Nil[A] val)
Parameters¶
Returns¶
map[B: B]¶
Mapping a function from A to B over the empty list yields the empty list of Bs.
fun box map[B: B](
f: {(val->A): val->B}[A, B] box)
: Nil[B] val
Parameters¶
- f: {(val->A): val->B}[A, B] box
Returns¶
- Nil[B] val
flat_map[B: B]¶
Flatmapping a function from A to B over the empty list yields the empty list of Bs.
fun box flat_map[B: B](
f: {(val->A): List[B]}[A, B] box)
: Nil[B] val
Parameters¶
- f: {(val->A): List[B]}[A, B] box
Returns¶
- Nil[B] val
for_each¶
Applying a function to every member of the empty list is a no-op.
fun box for_each(
f: {(val->A)}[A] box)
: None val
Parameters¶
- f: {(val->A)}[A] box
Returns¶
- None val
filter¶
Filtering the empty list yields the empty list.
fun box filter(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Nil[A] val
fold[B: B]¶
Folding over the empty list yields the initial accumulator.
fun box fold[B: B](
f: {(B, val->A): B^}[A, B] box,
acc: B)
: B
Parameters¶
- f: {(B, val->A): B^}[A, B] box
- acc: B
Returns¶
- B
every¶
Any predicate is true of every member of the empty list.
fun box every(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Bool val
exists¶
For any predicate, there is no element that satisfies it in the empty list.
fun box exists(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Bool val
partition¶
The only partition of the empty list is two empty lists.
fun box partition(
f: {(val->A): Bool}[A] box)
: (Nil[A] val , Nil[A] val)
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
drop¶
There are no elements to drop from the empty list.
fun box drop(
n: USize val)
: Nil[A] val
Parameters¶
- n: USize val
Returns¶
- Nil[A] val
drop_while¶
There are no elements to drop from the empty list.
fun box drop_while(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Nil[A] val
take¶
There are no elements to take from the empty list.
fun box take(
n: USize val)
: Nil[A] val
Parameters¶
- n: USize val
Returns¶
- Nil[A] val
take_while¶
There are no elements to take from the empty list.
fun box take_while(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
- f: {(val->A): Bool}[A] box
Returns¶
- Nil[A] val
contains[optional T: (A & HasEq[A!] #read)]¶
fun val contains[optional T: (A & HasEq[A!] #read)](
a: val->T)
: Bool val
Parameters¶
- a: val->T
Returns¶
- Bool val
eq¶
fun box eq(
that: Nil[A] val)
: Bool val
Parameters¶
- that: Nil[A] val
Returns¶
- Bool val
ne¶
fun box ne(
that: Nil[A] val)
: Bool val
Parameters¶
- that: Nil[A] val
Returns¶
- Bool val