Collections builtins
18 builtins of Soma 3.2.4 in the category Collections, with their exact signatures, as soma describe --builtins --json prints them.
list
list(items...) -> ListBuild a list of the arguments; list(list(1, 2), 3) is [[1, 2], 3]. Use push(xs, x) to append.
Used in verified programs:
- aerospace/launch_commit, line 45: return list("oring_temp", "range_clear", "upper_winds", "ice_team")
- agents/multi_agent_pipeline, line 15: let pts = list("intro to {topic}", "details", "conclusion")
- agents/planner, line 30: let tasks = list()
- agents/react_calculator, line 29: let out = list()
map
map(key, value, ...) -> Map | list |> map(x => expr) -> ListBuild a map from key-value pairs (even arg count), or — with a lambda — transform each list element.
Used in verified programs:
- aerospace/autopilot_authority, line 48: if r.error != () { return map("ok", false, "reason", "{r.error}") }
- aerospace/cabin_pressurization, line 52: if r.error != () { return map("ok", false, "reason", "{r.error}") }
- aerospace/cargo_door, line 55: if r.error != () { return map("ok", false, "reason", "{r.error}") }
- aerospace/docking_approach, line 51: if r.error != () { return map("ok", false, "reason", "{r.error}") }
push
push(list: List, items...) -> ListReturn a new list with the items appended (the original is unchanged).
Used in verified programs:
- agents/planner, line 32: tasks = push(tasks, map("n", i, "desc", "{goal} — step {i}"))
- agents/react_calculator, line 35: if is_prime { out = push(out, k) }
- agents/tool_dispatcher, line 28: for i in range(0, len(s)) { cs = push(cs, s[len(s) - 1 - i]) }
- algorithms/bfs, line 37: for i in range(1, len(queue)) { rest = push(rest, queue[i]) }
nth
nth(list: List, i: Int) -> AnyElement at index i, or () when out of bounds.
reverse
reverse(list: List) -> ListReturn the list in reverse order.
Used in verified programs:
- web/webhook_log, line 32: let all = _all() |> reverse()
range
range(start: Int, end: Int, step?: Int) -> List<Int>Integers from start toward end (exclusive); bounds and step are 64-bit Ints. A negative step counts down; zero raises kind range. Direct for-loops do not materialize the list, including stepped ranges.
Used in verified programs:
- agents/horde_audit, line 22: let docs = range(0, n) |> map(i => map("id", "doc-{i}", "text", "contract {i}: the supplier may terminate at will"))
- agents/horde_rounds, line 24: let people = range(0, state.get("n") ?? 10) |> map(i => map("id", "p{i}"))
- agents/planner, line 31: for i in range(1, steps + 1) {
- agents/react_calculator, line 30: for k in range(2, n) {
sort
sort(list: List, order?: "desc") -> ListSort scalars ascending (or "desc"); errors on incomparable element types.
Used in verified programs:
- civic/lottery, line 69: let pool = sort(entries.keys())
- math/statistics, line 36: let s = sort(xs)
flatten
flatten(list: List) -> ListFlatten one level of nested lists.
Used in verified programs:
- records/bst, line 54: return list(_walk(t.left), list(t.v), _walk(t.right)) |> flatten()
- records/family_tree, line 56: out = list(out, _collect(c, cur + 1, target)) |> flatten()
zip
zip(a: List, b: List) -> List<{left, right}>Pair elements positionally; stops at the shorter list.
Used in verified programs:
- math/vector_ops, line 21: let prods = zip(a, b) |> map(p => p.left * p.right)
enumerate
enumerate(list: List) -> List<{index, value}>Attach a 0-based index to each element.
Used in verified programs:
- records/inventory, line 39: for e in enumerate(items) {
with
with(m: Map, key, value, ...) -> Map | with(list: List, i: Int, value) -> ListCopy of the map with every key-value pair inserted, or copy of the list with element i replaced. An incomplete pair raises kind type; large Int map keys are stringified, while list indices must fit signed 64 bits.
Used in verified programs:
- data/cohort_retention, line 34: r |> with("retention_pct", rate)
- data/csv_transform, line 23: r |> with("net", net) |> with("tax", tax) |> with("gross", net + tax)
- data/expense_tracker, line 22: r |> with("kind", kind)
- data/leaderboard, line 30: out = out.push(rows[i] |> with("rank", i + 1))
without
without(m: Map, keys...) -> MapReturn a copy of the map with the given keys removed.
Used in verified programs:
- records/record_ops, line 25: return base() |> without("name", "age")
merge
merge(a: Map, b: Map, ...) -> MapCopy of a with all entries of b (and of each later map) inserted — a later map wins on conflict.
Used in verified programs:
- records/record_ops, line 30: return merge(base(), map("age", 31, "city", "London"))
join
join(list: List, sep: String) -> String | join(left: List, right: List, key) -> ListJoin list elements into a string — or, with two lists, an inner data join on key.
Used in verified programs:
- agents/react_calculator, line 37: out |> map(p => to_string(p)) |> join(",")
- agents/tool_dispatcher, line 29: join(cs, "")
- medical/prescription_lockout, line 81: let joined = join(push(current, drug), ",")
- text/acronym, line 30: return join(parts, "")
slice
slice(xs: List|String, start: Int, end?: Int) -> List|StringSub-list / substring, end exclusive; negative indexes count from the end (slice(xs, -2) = last two). Clamped, never raises.
keys
keys(m: Map) -> List<String>Keys of a map VALUE, in insertion order. (Memory slots: slot.keys().)
values
values(m: Map) -> ListValues of a map VALUE, in insertion order. (Memory slots: slot.values().)
entries
entries(m: Map) -> List<{key, value}>Key/value records of a map VALUE: for e in entries(m) { e.key e.value }.