type List<a> = recursive either { .end!, .item(a) self, }
A finite, ordered sequence of values.
*(1, 2, 3) // syntax sugar for .item(1) .item(2) .item(3) .end!
Finite list types and list combinators.
let xs = *(1, 2, 3)
xs->List.Map(box [n] n * 2)
type List<a> = recursive either { .end!, .item(a) self, }
A finite, ordered sequence of values.
*(1, 2, 3) // syntax sugar for .item(1) .item(2) .item(3) .end!
Incrementally constructs a list.
Returns .true! if the test function holds for all elements.
Short-circuits on the first .false!.
Returns .true! if the test function holds for at least one element.
Short-circuits on the first .true!.
dec List.Builder : [type a] List.Builder<a>
Creates a new list Builder.
Flattens a list of lists into a single list.
Yields all items from a source list onto a destination channel, consuming the source.
Drops the requested number of elements from the start of a list.
Drops elements from the start while the test function returns .true!.
Pairs each element with its zero-based index.
Keeps the elements for which the test function returns .true!.
Maps each element to an optional value, keeping only the present results.
Returns the first element for which the test function returns .true!.
Maps each element to a list, then concatenates the result.
Applies a folding function repeatedly to the current result and each list element, returning the final result.
Expression syntax:
{0}->List.ForEach(*(1, 2, 3), box [sum, n] sum + n)
// = 6
Process syntax:
let console = Console.Open
console->List.ForEach(Nat.Range(1, 10), box [c, i]
c.print(`#{i}`)
)
console.close
Returns the number of elements in a list.
Applies a mapping function to each element of a list.
{*(1, 2, 3)}->List.Map(box [n] n * 2)
// = *(2, 4, 6)
Returns the largest element, or .none! for an empty list.
Returns the smallest element, or .none! for an empty list.
Returns a list with the elements in reverse order.
Sorts a list in ascending data order. Equal keys keep their original order.
Sorts a non-linear list by an extracted data key.
Sorts a list in descending data order. Equal keys keep their original order.
dec List.SortDescBy : <a: box>[List<a>] <k: data>[box [a] k] List<a>
Sorts a non-linear list by an extracted data key in descending order.
dec List.SortLinearBy : <a>[List<a>] <k: data>[box [a] (k) a] List<a>
Sorts a linear list by a function that returns both the key and the item.
dec List.SortLinearDescBy : <a>[List<a>] <k: data>[box [a] (k) a] List<a>
Sorts a linear list by a key in descending order.
Calculates the sum of all elements in a list.
Returns up to the requested number of elements from the start of a list.
Takes elements from the start while the test function returns .true!.
Splits a list of pairs into a pair of lists.
Zips two lists into a list of pairs. Stops at the shorter list.