set¶
meth (Value: any):in(Set: set): any | nilReturns
Keyif it is inSet, otherwise returnnil.let S := set(["A", "B", "C"]) "A" in S :> "A" "D" in S :> nil
type set < sequenceA 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(): setReturns a new set.
set() :> {}
meth set(Sequence: sequence, ...): setReturns a set of all the values produced by
Sequence.set("cake") :> {c, a, k, e}
meth (Set₁: set) * (Set₂: set): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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): setReturns 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 | nilReturns
Valueif 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): setReturns 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):backwards: SequenceReturns a sequence which will iterate over
Setbackwards.map(set("abc"):backwards) :> {"c" is "c", "b" is "b", "a" is "a"}
meth (Set: set):count: integerReturns the number of values in
Set.set(["A", "B", "C"]):count :> 3
meth (Set: set):firstReturns the first value in
SetornilifSetis empty.meth (Set: set):first2Returns the first value in
SetornilifSetis empty.meth (Set: set):from(Value: any): sequence | nilReturns the subset of
SetafterValueas a sequence.let S := set(["A", "B", "C", "D", "E"]) set(S:from("C")) :> {C, D, E} set(S:from("F")) :> {}
meth (Set: set):lastReturns the last value in
SetornilifSetis empty.meth (Set: set):last2Returns the last value in
SetornilifSetis empty.meth (Set: set):order: set::orderReturns the current ordering of
Set.meth (Set: set):precount: integerReturns the number of values in
Set.set(["A", "B", "C"]):count :> 3
meth (List: set):random: anyReturns a random (assignable) node from
Set.let S := set("cake") :> {c, a, k, e} S:random :> "c" S:random :> "c"
meth (Set: set):size: integerReturns the number of values in
Set.set(["A", "B", "C"]):size :> 3
meth (Arg₁: set):subsetsTBD
meth (Arg₁: set):subsets(Arg₂: integer)TBD
meth (Buffer: string::buffer):append(Set: set)Appends a representation of
SettoBufferof 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
SettoBufferof 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 < setTBD
meth (Set: set::mutable):delete(Value: any): some | nilRemoves
ValuefromSetand 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: setDeletes all values from
Setand returns it.let S := set(["A", "B", "C"]) :> {A, B, C} S:empty :> {}
meth (Set: set::mutable):filter(Filter: function): mapRemoves every
ValuefromSetfor whichFunction(Value)returnsniland returns those values in a new map.let S := set(1 .. 20) S:filter(2 | _) :> {1 is <set::node>, 3 is 3, 5 is 5, 7 is 7, 9 is 9, 11 is 11, 13 is 13, 15 is 15, 17 is 17, 19 is 19} S :> {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
meth (Set: set::mutable):grow(Sequence: sequence, ...): setAdds of all the values produced by
SequencetoSetand returnsSet.set("cake"):grow("banana") :> {c, a, k, e, b, n}
meth (Set: set::mutable):insert(Value: any): some | nilInserts
ValueintoSet. Returns the previous value associated withKeyif 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 | nilIf
Valueis present inSetthen returnsnil. Otherwise insertsValueintoSetand 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): setSets the ordering
meth (Set: set::mutable):pop: any | nilDeletes the first value from
Setaccording to its iteration order. Returns the deleted value, ornilifSetis 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 | nilDeletes the last value from
Setaccording to its iteration order. Returns the deleted value, ornilifSetis 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, ...): setInserts each
ValueintoSetat 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, ...): setInserts each
ValueintoSetat 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):remove(Filter: function): mapRemoves every
ValuefromSetfor whichFunction(Value)doesn't returnniland returns those values in a new map.let S := set(1 .. 20) S:remove(2 | _) :> {2 is <set::node>, 4 is 4, 6 is 6, 8 is 8, 10 is 10, 12 is 12, 14 is 14, 16 is 16, 18 is 18, 20 is 20} S :> {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}
meth (Set: set::mutable):reverse: setReverses the iteration order of
Setin-place and returns it.let S := set("cake") :> {c, a, k, e} S:reverse :> {e, k, a, c}
meth (Set: set::mutable):sort: SetSorts the values (changes the iteration order) of
SetusingValueᵢ < Valueⱼand returnsSet.let S := set("cake") :> {c, a, k, e} S:sort :> {a, c, e, k}
meth (Set: set::mutable):sort(Cmp: function): SetSorts the values (changes the iteration order) of
SetusingCmp(Valueᵢ, Valueⱼ)and returnsSetlet S := set("cake") :> {c, a, k, e} S:sort(>) :> {k, e, c, a}
meth (Set: set::mutable):sort(Cmp: method): SetSorts the values (changes the iteration order) of
SetusingCmp(Valueᵢ, Valueⱼ)and returnsSetlet 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): setInserts the values from
SourceintoSet, leavingSourceempty.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): setReturns a new set contains copies of the elements of
Setcreated usingVisitor.meth (Visitor: visitor):copy(Set: set): setReturns a new set contains copies of the elements of
Setcreated usingCopy.meth (Visitor: visitor):visit(Set: set): setReturns a new set contains copies of the elements of
Setcreated usingCopy.