set

meth (Value: any):in(Set: set): any | nil

Returns Key if it is in Map, otherwise return nil.

let S := set(["A", "B", "C"])
"A" in S :> "A"
"D" in S :> nil
type set < sequence

A set of values. Values can be of any type supporting hashing and comparison. By default, iterating over a set generates the values in the order they were inserted, however this ordering can be changed.

meth set(): set

Returns a new set.

set() :> {}
meth set(Sequence: sequence, ...): set

Returns a set of all the values produced by Sequence.

set("cake") :> {c, a, k, e}
meth (Set₁: set) * (Set₂: set): set

Returns a new set containing the values of Set₁ which are also in Set₂.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A * B :> {b, a}
meth (Set₁: set) + (Set₂: set): set

Returns a new set combining the values of Set₁ and Set₂.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A + B :> {b, a, n, r, e, d}
meth (Set₁: set) / (Set₂: set): set

Returns a new set containing the values of Set₁ which are not in Set₂.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A / B :> {n}
meth (Set₁: set) /\ (Set₂: set): set

Returns a new set containing the values of Set₁ which are also in Set₂.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A /\ B :> {b, a}
meth (Set₁: set) < (Set₂: set): set

Returns a Set₂ if Set₁ is a strict subset of Set₂, otherwise returns nil.

let A := set("bandana") :> {b, a, n, d}
let B := set("ban") :> {b, a, n}
let C := set("bread") :> {b, r, e, a, d}
let D := set("bandana") :> {b, a, n, d}
B < A :> {b, a, n, d}
C < A :> nil
D < A :> nil
meth (Set₁: set) <= (Set₂: set): set

Returns a Set₂ if Set₁ is a subset of Set₂, otherwise returns nil.

let A := set("bandana") :> {b, a, n, d}
let B := set("ban") :> {b, a, n}
let C := set("bread") :> {b, r, e, a, d}
let D := set("bandana") :> {b, a, n, d}
B <= A :> {b, a, n, d}
C <= A :> nil
D <= A :> {b, a, n, d}
meth (Set₁: set) <=> (Set₂: set): set

Returns a tuple of (Set₁ / Set₂, Set₁ * Set₂, Set₂ / Set₁).

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A <=> B :> ({n}, {b, a}, {r, e, d})
meth (Set₁: set) > (Set₂: set): set

Returns a Set₂ if Set₁ is a strict superset of Set₂, otherwise returns nil.

let A := set("bandana") :> {b, a, n, d}
let B := set("ban") :> {b, a, n}
let C := set("bread") :> {b, r, e, a, d}
let D := set("bandana") :> {b, a, n, d}
A > B :> {b, a, n}
A > C :> nil
A > D :> nil
meth (Set₁: set) >< (Set₂: set): set

Returns a new set containing the values of Set₁ and Set₂ that are not in both.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A >< B :> {n, r, e, d}
meth (Set₁: set) >= (Set₂: set): set

Returns a Set₂ if Set₁ is a superset of Set₂, otherwise returns nil.

let A := set("bandana") :> {b, a, n, d}
let B := set("ban") :> {b, a, n}
let C := set("bread") :> {b, r, e, a, d}
let D := set("bandana") :> {b, a, n, d}
A >= B :> {b, a, n}
A >= C :> nil
A >= D :> {b, a, n, d}
meth (Set: set)[Value: any]: some | nil

Returns Value if it is in Set, otherwise returns nil..

let S := set(["A", "B", "C"])
S["A"] :> "A"
S["D"] :> nil
S :> {A, B, C}
meth (Set₁: set) \/ (Set₂: set): set

Returns a new set combining the values of Set₁ and Set₂.

let A := set("banana") :> {b, a, n}
let B := set("bread") :> {b, r, e, a, d}
A \/ B :> {b, a, n, r, e, d}
meth (Set: set):count: integer

Returns the number of values in Set.

set(["A", "B", "C"]):count :> 3
meth (Set: set):first

Returns the first value in Set or nil if Set is empty.

meth (Set: set):from(Value: any): sequence | nil

Returns the subset of Set after Value as a sequence.

let S := set(["A", "B", "C", "D", "E"])
set(S:from("C")) :> {C, D, E}
set(S:from("F")) :> {}
meth (Set: set):last

Returns the last value in Set or nil if Set is empty.

meth (Set: set):order: set::order

Returns the current ordering of Set.

meth (Set: set):precount: integer

Returns the number of values in Set.

set(["A", "B", "C"]):count :> 3
meth (List: set):random: any

Returns a random (assignable) node from Set.

let S := set("cake") :> {c, a, k, e}
S:random :> "a"
S:random :> "k"
meth (Set: set):size: integer

Returns the number of values in Set.

set(["A", "B", "C"]):size :> 3
meth (Buffer: string::buffer):append(Set: set)

Appends a representation of Set to Buffer.

meth (Buffer: string::buffer):append(Set: set, Sep: string)

Appends the values of Set to Buffer with Sep between values.

type set::mutable < set

TBD

meth (Set: set::mutable):delete(Value: any): some | nil

Removes Value from Set and returns it if found, otherwise nil.

let S := set(["A", "B", "C"])
S:delete("A") :> some
S:delete("D") :> nil
S :> {B, C}
meth (Set: set::mutable):empty: set

Deletes all values from Set and returns it.

let S := set(["A", "B", "C"]) :> {A, B, C}
S:empty :> {}
meth (Set: set::mutable):grow(Sequence: sequence, ...): set

Adds of all the values produced by Sequence to Set and returns Set.

set("cake"):grow("banana") :> {c, a, k, e, b, n}
meth (Set: set::mutable):insert(Value: any): some | nil

Inserts Value into Set. Returns the previous value associated with Key if any, otherwise nil.

let S := set(["A", "B", "C"])
S:insert("A") :> some
S:insert("D") :> nil
S :> {A, B, C, D}
meth (Set: set::mutable):missing(Value: any): some | nil

If Value is present in Set then returns nil. Otherwise inserts Value into Set and returns some.

let S := set(["A", "B", "C"])
S:missing("A") :> nil
S:missing("D") :> some
S :> {A, B, C, D}
meth (Set: set::mutable):order(Order: set::order): set

Sets the ordering

meth (Set: set::mutable):pop: any | nil

Deletes the first value from Set according to its iteration order. Returns the deleted value, or nil if Set is empty.

:> Insertion order (default)
let S1 := set("cake") :> {c, a, k, e}
S1:pop :> "c"
S1 :> {a, k, e}

:> LRU order
let S2 := set("cake"):order(set::order::LRU)
:> {c, a, k, e}
S2["a"]; S2["e"]; S2["c"]; S2["k"]
S2:pop :> "a"
S2 :> {e, c, k}

:> MRU order
let S3 := set("cake"):order(set::order::MRU)
:> {c, a, k, e}
S3["a"]; S3["e"]; S3["c"]; S3["k"]
S3:pop :> "k"
S3 :> {c, e, a}
meth (Set: set::mutable):pull: any | nil

Deletes the last value from Set according to its iteration order. Returns the deleted value, or nil if Set is empty.

:> Insertion order (default)
let S1 := set("cake") :> {c, a, k, e}
S1:pull :> "e"
S1 :> {c, a, k}

:> LRU order
let S2 := set("cake"):order(set::order::LRU)
:> {c, a, k, e}
S2["a"]; S2["e"]; S2["c"]; S2["k"]
S2:pull :> "k"
S2 :> {a, e, c}

:> MRU order
let S3 := set("cake"):order(set::order::MRU)
:> {c, a, k, e}
S3["a"]; S3["e"]; S3["c"]; S3["k"]
S3:pull :> "a"
S3 :> {k, c, e}
meth (Set: set::mutable):push(Value: any, ...): set

Inserts each Value into Set at the start.

let S := set(["A", "B", "C"])
S:push("A") :> {A, B, C}
S:push("D") :> {D, A, B, C}
S:push("E", "B") :> {B, E, D, A, C}
S :> {B, E, D, A, C}
meth (Set: set::mutable):put(Value: any, ...): set

Inserts each Value into Set at the end.

let S := set(["A", "B", "C"])
S:put("A") :> {B, C, A}
S:put("D") :> {B, C, A, D}
S:put("E", "B") :> {C, A, D, E, B}
S :> {C, A, D, E, B}
meth (Set: set::mutable):reverse: set

Reverses the iteration order of Set in-place and returns it.

let S := set("cake") :> {c, a, k, e}
S:reverse :> {e, k, a, c}
meth (Set: set::mutable):sort: Set

Sorts the values (changes the iteration order) of Set using Valueᵢ < Valueⱼ and returns Set.

let S := set("cake") :> {c, a, k, e}
S:sort :> {a, c, e, k}
meth (Set: set::mutable):sort(Cmp: function): Set

Sorts the values (changes the iteration order) of Set using Cmp(Valueᵢ, Valueⱼ) and returns Set

let S := set("cake") :> {c, a, k, e}
S:sort(>) :> {k, e, c, a}
type set::order < enum
  • ::Insert - default ordering; inserted values are put at end, no reordering on access.

  • ::LRU - inserted values are kept in ascending order, no reordering on access.

  • ::MRU - inserted values are kept in descending order, no reordering on access.

  • ::Ascending - inserted values are put at start, accessed values are moved to start.

  • ::Descending - inserted values are put at end, accessed values are moved to end.

meth (Visitor: visitor):const(Set: set): set

Returns a new set contains copies of the elements of Set created using Visitor.

meth (Visitor: visitor):copy(Set: set): set

Returns a new set contains copies of the elements of Set created using Copy.

meth (Visitor: visitor):visit(Set: set): set

Returns a new set contains copies of the elements of Set created using Copy.