Set difference (or nearest approximation)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Set difference (or nearest approximation)

Sophie424
What collection type / message should I use for set difference? I can't seem
to find any :-(

Sophie




Reply | Threaded
Open this post in threaded view
|

Re: Set difference (or nearest approximation)

Damien Cassou-3
2007/12/12, itsme213 <[hidden email]>:
> What collection type / message should I use for set difference? I can't seem
> to find any :-(

I do not understand what you mean with «set difference».

--
Damien Cassou


Reply | Threaded
Open this post in threaded view
|

Re: Set difference (or nearest approximation)

Lukas Renggli
In reply to this post by Sophie424
> What collection type / message should I use for set difference? I can't seem
> to find any :-(

#difference: ;-)

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: Set difference (or nearest approximation)

cedreek
In reply to this post by Sophie424
just playing around:

(#(1 2 3) asSet) difference:  (#(1 2 3 4 5) asSet)                 a Set()
(#(1 2 3 9) asSet) intersection:  (#(1 2 3 4 5) asSet)           a Set(1 2 3)
(#(1 2 3 9) asSet) copyWithoutAll:  (#(1 2 3 4 5) asSet)      a Set(9)
(#(1 2 3 4 5) asSet) copyWithoutAll:  (#(1 2 3 9) asSet)      a Set(5 4)
(#(1 2 3 4 5) asSet) union:  (#(1 2 3 9) asSet)                    a Set(1 2 3 4 5 9)


I think you'dlike   aSet (4 5 9)

| set1 set2 difference |
set1 := #(1 2 3 9) asSet.
set2 := #(1 2 3 4 5) asSet.
difference := (set1 union: set2) copyWithoutAll: (set1 intersection: set2)


or
| set1 set2 difference |
set1 := #(1 2 3 9) asSet.
set2 := #(1 2 3 4 5) asSet.
difference := (set1 copyWithoutAll: set2) addAll: (set2 copyWithoutAll: set1)


That's just a quick try...

Cédrick



2007/12/12, itsme213 < [hidden email]>:
What collection type / message should I use for set difference? I can't seem
to find any :-(

Sophie







Reply | Threaded
Open this post in threaded view
|

Re: Set difference (or nearest approximation)

cedreek


2007/12/12, cdrick <[hidden email]>:
just playing around:

(#(1 2 3) asSet) difference:  (#(1 2 3 4 5) asSet)                 a Set()

to be more complete:

#(1 2 9) asSet difference: #(1 3) asSet                 a Set(2 9)
#(1 2 3 9) asSet difference:  #(1 2 3 4 5) asSet     a Set(9)

is it the right definition of set differece ? 
aren't we expecting   union minus intersection ?




Reply | Threaded
Open this post in threaded view
|

Re: Set difference (or nearest approximation)

Daniel Vainsencher-3
In mathematical language, you are expecting a symmetric difference, but
what people in the math dept I learned in usually mean by set difference
is what Squeak seems to be doing. Wikipedia seems to agree [1].


[1] http://en.wikipedia.org/wiki/Complement_%28set_theory%29


Daniel


cdrick wrote:

>
>
> 2007/12/12, cdrick <[hidden email] <mailto:[hidden email]>>:
>
>     just playing around:
>
>     (#(1 2 3) asSet) difference:  (#(1 2 3 4 5) asSet)                
>     a Set()
>
>
> to be more complete:
>
> #(1 2 9) asSet difference: #(1 3) asSet                 a Set(2 9)
> #(1 2 3 9) asSet difference:  #(1 2 3 4 5) asSet     a Set(9)
>
> is it the right definition of set differece ?
> aren't we expecting   union minus intersection ?
>
>
> ------------------------------------------------------------------------
>
>
>