set¶
meth (Value: any):in(Set: set): any | nil
Returns
Key
if it is inMap
, otherwise returnnil
.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 inSet₂
.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₁
andSet₂
.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 inSet₂
.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 inSet₂
.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₂
ifSet₁
is a strict subset ofSet₂
, otherwise returnsnil
.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₂
ifSet₁
is a subset ofSet₂
, otherwise returnsnil
.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₂
ifSet₁
is a strict superset ofSet₂
, otherwise returnsnil
.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₁
andSet₂
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₂
ifSet₁
is a superset ofSet₂
, otherwise returnsnil
.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 inSet
, otherwise returnsnil
..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₁
andSet₂
.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
ornil
ifSet
is empty.meth (Set: set):from(Value: any): sequence | nil
Returns the subset of
Set
afterValue
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
ornil
ifSet
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 :> "e" S:random :> "c"
meth (Set: set):size: integer
Returns the number of values in
Set
.set(["A", "B", "C"]):size :> 3
meth (Arg₁: set):subsets
TBD
meth (Arg₁: set):subsets(Arg₂: integer)
TBD
meth (Buffer: string::buffer):append(Set: set)
Appends a representation of
Set
toBuffer
of the form"[" + repr(V₁) + ", " + repr(V₂) + ", " + ... + repr(Vₙ) + "]"
, whererepr(Vᵢ)
is a representation of the i-th element (using:append
).let B := string::buffer() B:append(set(1 .. 4)) B:rest :> "{1, 2, 3, 4}"
meth (Buffer: string::buffer):append(Set: set, Sep: string)
Appends a representation of
Set
toBuffer
of the formrepr(V₁) + Sep + repr(V₂) + Sep + ... + repr(Vₙ)
, whererepr(Vᵢ)
is a representation of the i-th element (using:append
).let B := string::buffer() B:append(set(1 .. 4), " - ") B:rest :> "1 - 2 - 3 - 4"
type set::mutable < set
TBD
meth (Set: set::mutable):delete(Value: any): some | nil
Removes
Value
fromSet
and returns it if found, otherwisenil
.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
toSet
and returnsSet
.set("cake"):grow("banana") :> {c, a, k, e, b, n}
meth (Set: set::mutable):insert(Value: any): some | nil
Inserts
Value
intoSet
. Returns the previous value associated withKey
if any, otherwisenil
.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 inSet
then returnsnil
. Otherwise insertsValue
intoSet
and returnssome
.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, ornil
ifSet
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, ornil
ifSet
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
intoSet
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
intoSet
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
usingValueᵢ < Valueⱼ
and returnsSet
.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
usingCmp(Valueᵢ, Valueⱼ)
and returnsSet
let S := set("cake") :> {c, a, k, e} S:sort(>) :> {k, e, c, a}
meth (Arg₁: set::mutable):splice(Arg₂: any)
TBD
meth (Arg₁: set::mutable):splice(Arg₂: any, Arg₃: integer)
TBD
meth (Arg₁: set::mutable):splice(Arg₂: any, Arg₃: integer, Arg₄: set::mutable)
TBD
meth (Arg₁: set::mutable):splice(Arg₂: any, Arg₃: set::mutable)
TBD
meth (Set: set::mutable):take(Source: set::mutable): set
Inserts the values from
Source
intoSet
, leavingSource
empty.let A := set("cat") :> {c, a, t} let B := set("cake") :> {c, a, k, e} A:take(B) :> {c, a, t, k, e} A :> {c, a, t, k, e} B :> {}
type set::order < enum
::Insert
- default ordering; inserted values are put at end, no reordering on access.::LRU
- inserted values are put at start, accessed values are moved to start.::MRU
- inserted values are put at end, accessed values are moved to end.::Ascending
- inserted values are kept in ascending order, no reordering on access.::Descending
- inserted values are kept in descending order, no reordering on access.
meth (Visitor: visitor):const(Set: set): set
Returns a new set contains copies of the elements of
Set
created usingVisitor
.meth (Visitor: visitor):copy(Set: set): set
Returns a new set contains copies of the elements of
Set
created usingCopy
.meth (Visitor: visitor):visit(Set: set): set
Returns a new set contains copies of the elements of
Set
created usingCopy
.