Collections

silt has three built-in collection types: list (ordered sequence), map (key → value), and set (unique elements). All three are immutable — every “mutating” operation returns a new collection.

Choosing a collection

You need …Use
an ordered sequence, index-addressable, duplicates allowedlist
lookup by key, one value per keymap
membership test, uniqueness, set algebra (union / intersection)set
a fixed-shape heterogeneous recordrecord (see Types)
a fixed-size heterogeneous sequencetuple

Rule of thumb: if you know the field names at compile time, use a record or tuple. Reach for a map only when keys are dynamic.

Pattern matching works on lists and maps — see Pattern Matching for [head, ..tail] and #{ "k": v }. Sets have no pattern form; test membership with set.contains instead.

Lists

Ordered, homogeneous collections:

let numbers = [1, 2, 3, 4, 5]

Spread in list literals with ..:

let full = [1, ..tail]
let merged = [..a, 3, ..b]

Key functions: list.map, list.filter, list.fold, list.each, list.find, list.zip, list.flatten, list.flat_map, list.filter_map, list.sort_by, list.any, list.all, list.head, list.tail, list.last, list.length, list.contains, list.append, list.concat, list.reverse, list.get, list.take, list.drop, list.enumerate, list.group_by, list.fold_until, list.unfold.

For the full reference, hover over any list.* call in your editor (the LSP renders the inlined builtin docs), or browse the LSP’s completion popup on list. to scan the full menu of entry points.

Maps

Key-ordered key-value collections with #{ }. Iteration visits entries in sorted key order. Keys can be any comparable type:

let config = #{ "host": "localhost", "port": "8080" }
let grid = #{ (0, 0): "start", (1, 2): "end" }

Use map.contains to check key membership.

Maps are homogeneous — all values must be the same type. This is enforced by the type system. For heterogeneous data, use records:

-- ERROR: mixed String and Int values
let m = #{ "name": "Alice", "age": 30 }

-- OK: use a record
type Person {
  name: String,
  age: Int,
}

Design rationale. Heterogeneous maps defeat static typing. If the type checker cannot know what map.get(m, key) returns, it cannot catch errors at compile time. See Design Decisions for the full argument.

Key functions: map.get, map.set, map.delete, map.contains, map.keys, map.values, map.entries, map.from_entries, map.length, map.merge, map.filter, map.map, map.each, map.update.

For the full reference, hover over any map.* call in your editor (the LSP renders the inlined builtin docs), or browse the LSP’s completion popup on map. to scan the full menu of entry points.

Sets

Sorted unique-value collections with #[ ]. Iteration visits elements in sorted order:

let tags = #[1, 2, 3]
let words = #["hello", "world", "hello"] -- duplicates removed

Set equality with ==/!= works:

println(#[1, 2, 3] == #[3, 2, 1]) -- true

Key functions: set.new, set.from_list, set.to_list, set.contains, set.insert, set.remove, set.length, set.union, set.intersection, set.difference, set.is_subset, set.map, set.filter, set.each, set.fold.

For the full reference, hover over any set.* call in your editor (the LSP renders the inlined builtin docs), or browse the LSP’s completion popup on set. to scan the full menu of entry points.