/Pony

# Nil[A: A]

[Source]

The empty list of As.

```primitive val Nil[A: A] is
```

## Constructors

### create

[Source]

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

## Public Functions

### size

[Source]

Returns the size of the list.

```fun box size()
: USize val
```

### 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 ?
```

• val->A ?

### values

[Source]

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

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

### is_empty

[Source]

Returns a Bool indicating if the list is empty.

```fun box is_empty()
: Bool val
```

### 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 ?
```

• val->A ?

### tail

[Source]

Returns an error, since Nil has no tail.

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

### reverse

[Source]

The reverse of the empty list is the empty list.

```fun box reverse()
: Nil[A] val
```

### 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
```

• a: val->A!

### 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)
```

### 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

### 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

### 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

### 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

### 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

• 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

### 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

### 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

### drop

[Source]

There are no elements to drop from the empty list.

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

### 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

### take

[Source]

There are no elements to take from the empty list.

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

### 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

### contains[optional T: (A & HasEq[A!] #read)]

[Source]

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

• a: val->T

### eq

[Source]

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

#### Parameters

• that: Nil[A] val

### ne

[Source]

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

#### Parameters

• that: Nil[A] val