Skip to content

Nil[A: A]

[Source]

The empty list of As.

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

Implements


Constructors

create

[Source]

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

Returns


Public Functions

size

[Source]

Returns the size of the list.

fun box size()
: USize val

Returns


apply

[Source]

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

[Source]

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

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

Returns


is_empty

[Source]

Returns a Bool indicating if the list is empty.

fun box is_empty()
: Bool val

Returns


is_non_empty

[Source]

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

fun box is_non_empty()
: Bool val

Returns


[Source]

Returns an error, since Nil has no head.

fun box head()
: val->A ?

Returns

  • val->A ?

tail

[Source]

Returns an error, since Nil has no tail.

fun box tail()
: (Cons[A] val | Nil[A] val) ?

Returns


reverse

[Source]

The reverse of the empty list is the empty list.

fun box reverse()
: Nil[A] val

Returns


prepend

[Source]

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

[Source]

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]

[Source]

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]

[Source]

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

[Source]

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

[Source]

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]

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

There are no elements to drop from the empty list.

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

Parameters

Returns


drop_while

[Source]

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

[Source]

There are no elements to take from the empty list.

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

Parameters

Returns


take_while

[Source]

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)]

[Source]

fun val contains[optional T: (A & HasEq[A!] #read)](
  a: val->T)
: Bool val

Parameters

  • a: val->T

Returns


eq

[Source]

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

Parameters

  • that: Nil[A] val

Returns


ne

[Source]

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

Parameters

  • that: Nil[A] val

Returns