Nil[A: A]

The empty list of As.

primitive val Nil[A: A] is
  ReadSeq[val->A] box

Implements


Constructors

create

new val create()
: Nil[A] val^

Returns


Public Functions

size

Returns the size of the list.

fun box size()
: USize val

Returns


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

Returns

  • val->A ?

values

Returns an empty iterator over the elements of the empty list.

fun box values()
: Iterator[val->A] ref^

Returns


is_empty

Returns a Bool indicating if the list is empty.

fun box is_empty()
: Bool val

Returns


is_non_empty

Returns a Bool indicating if the list is non-empty.

fun box is_non_empty()
: Bool val

Returns


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


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


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


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


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


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


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


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


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

Returns


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


take

There are no elements to take from the empty list.

fun box take(
  n: USize val)
: Nil[A] val

Parameters

Returns


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


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


eq

fun box eq(
  that: Nil[A] val)
: Bool val

Parameters

  • that: Nil[A] val

Returns


ne

fun box ne(
  that: Nil[A] val)
: Bool val

Parameters

  • that: Nil[A] val

Returns