Support of algebraic operations on sets
bert at freudenbergs.de
Fri Jun 15 11:31:45 UTC 2007
On Jun 15, 2007, at 13:24 , sig wrote:
> I would like to ask community, why there's no methods in Set class
> which support macro operations with sets like
> There's only a #union: method, in my 3.8 , and i wonder, why there's
> no #intersect: and #subtract: ?
> These are common algebraic operations on sets, and i really missing
> them: i have to modify one set by comparing it with another and
> add/remove elements based on this comparison. Currently i forced to
> implement intersection/subtraction operations each time i need them,
> but i would really like to see these operations in standard Set
> Or, if someone knows, please describe the reasons why these operations
> was not included in standard Set protocol?
Because they are included in the standard Collection protocol, no
special need to implement them for Sets:
#(1 2 3) asSet union: #(3 4 5) asSet "a Set(1 2 3 4 5)"
#(1 2 3) asSet intersection: #(3 4 5) asSet "a Set(3)"
#(1 2 3) asSet difference: #(3 4 5) asSet "a Set(1 2)"
You should start using the protocol browser.
- Bert -
More information about the Squeak-dev