Set Library
Stof's standard set library ("Set").
Sets in Stof are ordered and can contain a mixture of types. Within each type, values are ordered as you would expect.
Mixed-Value Ordering:
Null values
Booleans
Numbers
Strings
Objects - sorted by ID
Functions - sorted by ID
Arrays/Vectors
Tuples
Blobs
Sets
Maps
Common Value Functions
Set.toString(set: set): str
Returns a set converted to a string. This performs the same as "std.pln(set)" and "std.dbg(set)".
Set.or(set: set, ...): unknown
Returns the first non-empty (null or void) argument, just like the Standard Library "or" function.
Set Functions
Set.append(set: set, other: set): void
Move all values in "other" to this set, leaving "other" empty.
Set.clear(set: set): void
Remove all values in this set.
Set.contains(set: set, val: unknown): bool
Does this set contain the value?
Set.first(set: set): unknown
Returns the first value in this set, or null if the set is empty.
Set.last(set: set): unknown
Returns the last value in this set, or null if the set is empty.
Set.insert(set: set, val: unknown): bool
Insert a value into this set, returning true if this value is newly inserted.
Set.take(set: set, val: unknown): unknown
Take a value from this set if the set contains it (removing the value from the set).
Set.split(set: set, val: unknown): set
Split this set into another set at the given value.
Set.empty(set: set): bool
Is this set empty?
Set.any(set: set): bool
Does this set contain any values?
Set.len(set: set): int
Returns the length of this set (the number of elements it contains).
Set.at(set: set, index: int): unknown
Get a value in this set at the given index.
Set.popFirst(set: set): unknown
Remove the first value in the set and return it.
Set.popLast(set: set): unknown
Remove the last value in the set and return it.
Set.remove(set: set, val: unknown): bool
Remove a value from this set, returning true if the value existed.
Set.retain(set: set, func: fn): void
Retain only the elements specified by the predicate.
Set.union(set: set, other: set): set
Union this set with another, returning a new set.
Set.difference(set: set, other: set): set
Return a new set which is the difference between this set and another.
Set.intersection(set: set, other: set): set
Return a new set which is the intersection between this set and another.
Set.symmetricDifference(set: set, other: set): set
Return a new set which is the symmetric difference between this set and another.
Set.disjoint(set: set, other: set): bool
Returns true if this set has no elements in common with another.
Set.subset(set: set, other: set): bool
Returns true if this set is a subset of another.
Set.superset(set: set, other: set): bool
Returns true if this set is a superset of another.
Last updated