gossamer/set
Types
A JS Set holding unique values of any type, preserving insertion
order. Mutable — methods modify the set in place and return it for
chaining.
For most Gleam use cases, prefer gleam/set.Set. This binding exists
for JS interop where a JS Set is specifically required.
Object values (records, lists, tuples) are matched by JS reference
identity, not value equality — two equal-by-value tuples constructed
separately are distinct values. Primitive values (Int, Float,
String, Bool) use value equality.
See Set on MDN.
pub type Set(value)
Values
pub fn add(to set: Set(value), value value: value) -> Set(value)
Adds a value to the set. Mutates the set.
pub fn delete(
from set: Set(value),
value value: value,
) -> Set(value)
Removes the value from the set. Mutates the set.
pub fn difference(
from set: Set(value),
without other: Set(value),
) -> Set(value)
Returns a new set containing values in this set but not in the other.
pub fn entries(
of set: Set(value),
) -> iterator.Iterator(#(value, value), Nil, Nil)
pub fn intersection(
of set: Set(value),
and other: Set(value),
) -> Set(value)
Returns a new set containing values present in both sets.
pub fn symmetric_difference(
of set: Set(value),
and other: Set(value),
) -> Set(value)
Returns a new set containing values in either set but not both.
pub fn union(
of set: Set(value),
and other: Set(value),
) -> Set(value)
Returns a new set containing all values from both sets.
pub fn values(
of set: Set(value),
) -> iterator.Iterator(value, Nil, Nil)