Collections
Arrays
Section titled “Arrays”nums := [1, 2, 3]names := ["Ada", "Bo"]empty: [int] = []Homogeneous and dynamically sized. + concatenates. See std.vec for
push, pop, sort, reverse, join, contains, insert, remove.
Insertion-ordered, O(n) lookup:
ages := {"Ada": 30, "Bo": 25}ages["Cy"] = 41Prefer std.map.get_or(d, key, default) over direct index when keys may miss.
std.map.keys/values/merge/remove are pure helpers.
Tuples
Section titled “Tuples”Fixed shape, integer-literal index only (checked at compile time):
t := (7, "seven")t[0] // 7t[-1] // "seven"len(t) // 2
(a, b) := t // destructure; _ skipsc, d := t // bare form, same meaningDynamic t[i] is a compile error — destructure instead. Tuples share the
array representation: t[0] = 99 writes in place on both engines.
Slicing
Section titled “Slicing”arr := [10, 20, 30, 40]arr[0] // 10arr[-1] // 40arr[1:3] // [20, 30]arr[:2] // [10, 20]arr[2:] // [30, 40]s := "hello"s[1:3] // "el"Comprehensions
Section titled “Comprehensions”squares := [x ** 2 for x in range(0, 6)]evens := [x for x in range(21) if x % 2 == 0]Pipelines and higher-order built-ins
Section titled “Pipelines and higher-order built-ins”result := range(1, 6) |> map(|x| x * 2) |> filter(|x| x > 4)map, filter, enumerate, zip work bare and as std.vec.*.
Prefer std.vec.* in new code; bare forms stay until 0.3.
Ranges
Section titled “Ranges”0..5 is 0,1,2,3,4. range(stop) / range(start, stop) / range(start, stop, step).
len works on arrays, tuples, bytes, strings, dicts, ranges.
Next: Structs and enums.