Lists
A list<T> is an ordered, homogeneous sequence of values of type T. Lists are how you write any "many of the same thing" — including the data flowing through @children, @connections, and table rows.
Literals
Write a list literal with square brackets and commas. The element type is inferred from its contents (or pinned by the field's declared type).
xs: list<i64> = [1, 2, 3, 4]
names: list<utf8> = ["alice", "bob"]
empty: list<i64> = []
Nested lists
List elements can themselves be lists. Use this for matrices, lookup tables, or any rectangular grid.
grid: list<list<i64>> = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
Working with lists
The collection builtins — map, filter, fold, len, sum, head, tail, range, flatten, zip, reverse, sort, unique, list_contains, index_of, at, take, drop — operate on list<T>. See Builtin Functions for signatures.
doubled = map([1, 2, 3], fn(x: i64) -> i64 x * 2) // [2, 4, 6]
evens = filter(range(0, 10), fn(x: i64) -> bool x % 2 == 0)
total = fold([1, 2, 3], 0, fn(a: i64, x: i64) -> i64 a + x)
Tabular data lives in lists
A field declared list<RowType> can be populated either by a list literal or by WCL's pipe-row table syntax — see Tables.