Collection functions
Transform, search, and reshape lists and tensors.
| Function | Description |
|---|---|
| [all(xs: [T], pred: fn (T) -> bool) → bool](functionfnall) | true when the predicate holds for every element (short-circuits; true for an empty list). |
| [any(xs: [T], pred: fn (T) -> bool) → bool](functionfnany) | true when the predicate holds for at least one element (short-circuits). |
| [at(xs: [T], i: i64) → T](functionfnat) | The element at a zero-based index; errors if out of bounds or negative. |
| [drop(xs: [T], n: i64) → [T]](functionfndrop) | Every element of a list after the first n. |
| [enumerate(xs: [T]) → [[i64, T]]](functionfnenumerate) | Pair every element with its zero-based index, as [index, element] pairs. |
| [filter(xs: [T], pred: fn (T) -> bool) → [T]](functionfnfilter) | Keep only the list elements for which the predicate returns true. |
| [find(xs: [T], pred: fn (T) -> bool) → T](functionfnfind) | The first element for which the predicate returns true, or none. |
| [flatten(xss: [[T]]) → [T]](functionfnflatten) | Concatenate a list of lists into a single list, one level deep. |
| [fold(xs: [T], init: U, f: fn (U, T) -> U) → U](functionfnfold) | Reduce a list or tensor to a single value by repeatedly combining the accumulator with each element. |
| [group_by(xs: [T], key: fn (T) -> K) → [record]](functionfngroup_by) | Group elements by a key function into { key, items } records, in first-seen key order. |
| [head(xs: [T]) → T](functionfnhead) | The first element of a list or tensor (none when empty). |
| [index_of(xs: [T], needle: T) → i64](functionfnindex_of) | The index of the first element equal to needle, or -1 if absent. |
| [len(xs: [T]) → usize](functionfnlen) | The number of elements in a list or tensor, or characters in a string. |
| [list_contains(xs: [T], needle: T) → bool](functionfnlist_contains) | Whether a list contains a value equal to needle. |
| [map(xs: [T], f: fn (T) -> U) → [U]](functionfnmap) | Apply a function to every element of a list or tensor, returning the transformed collection. |
| [max_by(xs: [T], key: fn (T) -> K) → T](functionfnmax_by) | The element with the largest key, or none for an empty list. |
| [min_by(xs: [T], key: fn (T) -> K) → T](functionfnmin_by) | The element with the smallest key, or none for an empty list. |
| [range(start: i64, end: i64) → [i64]](functionfnrange) | The half-open integer range [start, end) as a list. |
| [reverse(xs: [T]) → [T]](functionfnreverse) | Reverse the order of a list's elements. |
| [slice(xs: utf8 | [T], start: i64, end: i64) → utf8 | [T]](functionfnslice) | The half-open range [start, end) of a string's characters or a list's elements (bounds are clamped). |
| [sort(xs: [T]) → [T]](functionfnsort) | Sort a list — numerically for all-numeric lists, lexicographically for all-string lists. |
| [sort_by(xs: [T], key: fn (T) -> K) → [T]](functionfnsort_by) | Sort a list by a key function (stable). Keys must be all numeric or all strings. |
| [sort_connected(items: [T], edges: [{source, destination, ...}]) → [T]](functionfnsort_connected) | Reorder a list so that items joined by edges cluster together (recursing into children). |
| [sum(xs: [number]) → number](functionfnsum) | Add together every element of a non-empty homogeneous numeric list or tensor. |
| [tail(xs: [T]) → [T]](functionfntail) | Every element of a list or tensor except the first. |
| [take(xs: [T], n: i64) → [T]](functionfntake) | The first n elements of a list (fewer if the list is shorter). |
| [unique(xs: [T]) → [T]](functionfnunique) | Remove duplicate elements from a list, keeping first-seen order. |
| [zip(a: [A], b: [B]) → [(A, B)]](functionfnzip) | Pair up elements of two lists by index, stopping at the shorter length. |