I have to think if the asSet is needed too. In fact I want in addition
intersectionAndDifferences: aColl because I want to be able to define nicely merge: aDict onKeyConflictDoValues: aBlock as follow | d d2 | d := #(1 3 4 5 ) groupedBy: #even. d2 := #(10 31 41 50 ) groupedBy: #even. d merge: d2 onKeyConflictDoValues: [ :aValue :anotherValue | (aValue, anotherValue) asSet asOrderedCollection ] Because manipulating dictionaries whose values are collections is boring. Stef On 14 Mar 2014, at 23:15, Sven Van Caekenberghe <s...@stfx.eu> wrote: > Are the final #asArray conversions always needed ? > If not, it would be more efficient not to do them every time, no ? > > On 14 Mar 2014, at 22:19, Pharo4Stef <pharo4s...@free.fr> wrote: > >> something like that >> >> diffs: aCollection >> "Answer the set theoretic differences of two collections. The first >> element of the result is the difference from the perspective of the receiver >> and the second element the difference from the perspective of the argument." >> >> "#(a b c d e f) diffs: #(a b z k) #(#a #b #c #d #e #f) >> { #(#f #d #e #c) . #(#k #z)} >> " >> "{ self difference: aCollection . aCollection difference: self }" >> >> | receiver another | >> receiver := self asSet. >> another := aCollection asSet. >> self do: [ :each | >> (another includes: each) >> ifTrue: [ receiver remove: each. >> another >> remove: each ]]. >> ^ { receiver asArray . another asArray} >> > >