Skip to content

std.collections

std.collections is the standard library’s own toolbox of small, pure helpers for lists and strings. Every function here has an empty effect row !{} — they compute and nothing else — which is why the rest of the stdlib (and document in particular) builds on them.

from std.collections import join_str, join_ints, join_floats, dedup_ints, r6

These are the little utilities that would otherwise be re-inlined in every module: joining a list into a delimited string, rounding to a stable number of decimals for display, de-duplicating while preserving order. Centralizing them keeps the rest of the stdlib compact and gives your own deterministic core the same building blocks. For the primitive collection types (list, dict, tuple) themselves, see Types.

join_str joins a list of strings with a separator. join_ints and join_floats stringify first (floats via r6, below):

join_str(["a", "b", "c"], ", ") # "a, b, c"
join_ints([1, 2, 3], "-") # "1-2-3"
join_floats([0.1, 0.25], " | ") # "0.1 | 0.25"

r6 rounds to six decimal places, so numeric output is stable and comparable across runs (no long floating-point tails):

r6(0.12345678) # 0.123457

join_floats uses r6 internally, so a list of floats renders consistently.

dedup_ints removes duplicate integers while keeping first-seen order — useful for collapsing a list of ids without sorting it:

dedup_ints([3, 1, 3, 2, 1]) # [3, 1, 2]

See the full signature list in the generated std.collections API reference.