why? Iterators are powerful and avoid that we all reinvent the wheel in our own corners.
About keySelect: I do not see the point to convert a large collection into a dictionary then do yet another pass. To me it looks like a hack. I implemented selectEvery: (selectFirst selectSecond) as helpers. and also unzip all in one pass. Now I have no problem to keep them for me but to me this is the wrong attitude. Stef testSelectEveryFirst self assert: (#(#Object #subclass: #Point #instanceVariableNames: 'x y' #classVariableNames: '' #package: 'Kernel-BasicObjects') selectEveryFirst) asArray equals: #(#Object #Point 'x y' '' 'Kernel-BasicObjects') testSelectEverySecond self assert: (#(#Object #subclass: #Point #instanceVariableNames: 'x y' #classVariableNames: '' #package: 'Kernel-BasicObjects') selectEverySecond) asArray equals: #(#subclass: #instanceVariableNames: #classVariableNames: #package:) testUnzip | uz | uz := #(#Object #subclass: #Point #instanceVariableNames: 'x y' #classVariableNames: '' #package: 'Kernel-BasicObjects') unzip. self assert: uz first asArray equals: #(#Object #Point 'x y' '' 'Kernel-BasicObjects'). self assert: uz second asArray equals: #(#subclass: #instanceVariableNames: #classVariableNames: #package:) On Wed, Apr 19, 2017 at 9:05 PM, Esteban A. Maringolo <[email protected]> wrote: > 2017-04-19 15:43 GMT-03:00 Stephane Ducasse <[email protected]>: > > Hi > > > > I have > > > > #(#Object #subclass: #Point #instanceVariableNames: 'x y' > > #classVariableNames: '' #package: 'Kernel-BasicObjects') and I would > like to > > select on the second elements. > > > > I was thinking that > > > > #(#Object #subclass: #Point #instanceVariableNames: 'x y' > > #classVariableNames: '' #package: 'Kernel-BasicObjects') selectEvery: [ > :i | > > i \\ 2 = 0 ] > > could be a nice iterator. > > > > What do you think? > > I think I wouldn't add a new enumerating selector to the core classes. > > If it needs to be there, I would replace it by #keysSelect: > > So it would work to select based on the keys of the receiver (indexes > for sequenced collections) but also would work as it does for > #keysAndValuesDo: implementors. > > Regards, > > > -- > Esteban. > >
