Incrementally constructs a list.
Module List
Finite list types and list combinators.
let xs = *(1, 2, 3)
xs->List.Map(type Int, box [n] n * 2)
A list that ends with Result<e, !> instead of !.
Use it for streams that may finish with an error.
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!
Returns .true! if the predicate holds for all elements.
Short-circuits on the first .false!.
Returns .true! if the predicate 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 first n elements of a list and returns the rest.
Keeps the elements for which the predicate returns .true!.
Applies f to each element and concatenates the resulting lists.
Applies f 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 f to each element of a list.
{*(1, 2, 3)}->List.Map(type Int, box [n] n * 2)
// = *(2, 4, 6)
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>] [type 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>] [type 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>] [type 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 the first n elements of a list.
Splits a list of pairs into a pair of lists.
Zips two lists into a list of pairs. Stops at the shorter list.