set

.zn module

Set operations backed by [string, bool] maps (keys are strings; use string(v) to hash arbitrary values). import "set".

set.new() => [string, bool]

Empty set.

set.from(items: [string]) => [string, bool]

Build a set from a list.

set.add(s, item: string)

Add an element (mutates).

set.remove(s, item: string)

Remove an element (no-op if absent).

set.has(s, item: string) => bool

Membership test.

set.size(s) => int

Element count.

set.to_list(s) => [string]

Elements as a list, in insertion order (a set is backed by a map, which preserves insertion order).

set.union(a, b) => [string, bool]

Elements in either.

set.intersection(a, b) => [string, bool]

Elements in both.

set.difference(a, b) => [string, bool]

In a but not b.

set.sym_difference(a, b) => [string, bool]

In exactly one.

set.is_subset(a, b) => bool

Every element of a in b.

set.is_disjoint(a, b) => bool

No common elements.

On this page