Skip to content

std.set - ZZ

Set helpers over arrays — uniqueness enforced by helpers. Sets are [T] arrays with *_int variants for [int]. Immutable style: helpers return new arrays.

import std.set

std.set treats arrays as mathematical sets: insert-if-absent, union, intersection, difference, membership. Helpers are pure and return new arrays — the input is never mutated. Use for deduplication, membership testing, and set algebra on small-to-medium collections.

import std.set
set.insert(["a"], "b") // ["a", "b"]
set.insert(["a"], "a") // ["a"] (no-op, already present)
set.union(["a"], ["b"]) // ["a", "b"]
set.intersect(["a", "b"], ["b", "c"]) // ["b"]
set.diff(["a", "b"], ["b"]) // ["a"]
set.has(["a", "b"], "a") // true

13 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.

Function Signature Description
std.set.diff diff(a: [str], b: [str]) -> [str] Elements of a not in b
std.set.has has(s: [str], x: str) -> bool Membership
std.set.has_int has_int(s: [int], x: int) -> bool [int] membership
std.set.insert insert(s: [str], x: str) -> [str] Append if absent
std.set.insert_int insert_int(s: [int], x: int) -> [int] [int] insert-if-absent
std.set.intersect intersect(a: [str], b: [str]) -> [str] Common elements
std.set.intersect_int intersect_int(a: [int], b: [int]) -> [int] [int] intersect
std.set.is_empty is_empty(s: [str]) -> bool Empty check
std.set.len len(s: [str]) -> int Size
std.set.remove remove(s: [str], x: str) -> [str] Copy without element
std.set.remove_int remove_int(s: [int], x: int) -> [int] [int] remove
std.set.union union(a: [str], b: [str]) -> [str] Deduplicated concat
std.set.union_int union_int(a: [int], b: [int]) -> [int] [int] union
  • std.json — Parse, stringify and read individual values out of JSON.
  • std.map — Pure dictionary helpers over plain maps: lookup, merge and keys.
  • std.dec — Exact decimal arithmetic carried as strings, so money never becomes a float.
  • std.csv — An RFC 4180 subset: read rows, write rows, handle quotes and commas.
  • std.property — Seeded generators and shrinking for property-based tests.

Full index: API reference · Standard library