33 lines
515 B
Markdown
33 lines
515 B
Markdown
# Lists
|
|
|
|
Lists are a standard Ava type. Specifically `[A]` represents a linked list.
|
|
|
|
```
|
|
let x: [Int32] := [1, 2, 3]
|
|
let y := prepend x 0
|
|
let alt_y := 0 :- x
|
|
let z := append x [4, 5]
|
|
let w: Option[Int32] := head x
|
|
let tail: [Int32] := tail x
|
|
let sz: [Int32] := size x
|
|
```
|
|
|
|
## Type Class Support
|
|
|
|
- `Monad`
|
|
- `Monoid`
|
|
- `Show`
|
|
- `Eq`
|
|
|
|
## NonEmptyList
|
|
|
|
The type `NonEmptyList` is a list which cannot be empty:
|
|
|
|
```
|
|
given A
|
|
record NonEmptyList(head: A, tail: [A])
|
|
```
|
|
|
|
## Indexing
|
|
|
|
Lists cannot be accessed by index.
|