Support of algebraic operations on sets

Gary Chambers gazzaguru2 at
Fri Jun 15 11:52:47 UTC 2007

Note that #difference: is the relative complement of the two sets, rather
than the symmetric difference.
Perhaps we could have a method for that too!

-----Original Message-----
From: squeak-dev-bounces at
[mailto:squeak-dev-bounces at] On Behalf Of Bert
Sent: 15 June 2007 12:32 pm
To: sig
Cc: The general-purpose Squeak developers list
Subject: Re: Support of algebraic operations on sets

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 
> intersection/subtraction. 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
> protocol.
> 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 mailing list