Expand description
The list module — 32 functions (31 spec + 5 extensions + some alias).
All operations are immutable — they return new lists, never mutate.
§Construction (4)
| Function | Signature |
|---|---|
list.empty | () -> list |
list.of | (...items) -> list (variadic) |
list.repeat | (value, count: number) -> list |
list.range | (start: number, end: number) -> list |
§Access (5)
| Function | Signature |
|---|---|
list.length | (items: list) -> number |
list.get | (items: list, index: number) -> any|nil |
list.first | (items: list) -> any|nil |
list.last | (items: list) -> any|nil |
list.index_of | (items: list, value) -> number |
§Modification (10)
| Function | Signature |
|---|---|
list.append | (items: list, value) -> list |
list.prepend | (items: list, value) -> list |
list.insert | (items: list, index: number, value) -> list |
list.remove | (items: list, index: number) -> list |
list.update | (items: list, index: number, value) -> list |
list.slice | (items: list, start: number, end: number) -> list |
list.concat | (a: list, b: list) -> list |
list.reverse | (items: list) -> list |
list.flatten | (items: list) -> list |
list.unique | (items: list) -> list |
§Higher-Order (9)
| Function | Signature |
|---|---|
list.map | (items: list, f: fn(any) -> any) -> list |
list.filter | (items: list, pred: fn(any) -> bool) -> list |
list.reduce | (items: list, init, f: fn(acc, item) -> acc) -> any |
list.find | (items: list, pred: fn(any) -> bool) -> any|nil |
list.find_index | (items: list, pred: fn(any) -> bool) -> number |
list.every | (items: list, pred: fn(any) -> bool) -> bool |
list.any | (items: list, pred: fn(any) -> bool) -> bool |
list.sort | (items: list, cmp: fn(a, b) -> number) -> list |
list.count | (items: list, pred: fn(any) -> bool) -> number |
§Query (4) — also non-higher-order
| Function | Signature |
|---|---|
list.contains | (items: list, value) -> bool |
list.zip | (a: list, b: list) -> list |
list.take | (items: list, n: number) -> list |
list.drop | (items: list, n: number) -> list |
Structs§
- List
Module - The
liststdlib module.