2017-04-20 17:06 GMT+02:00 Ben Coman <btc@openinworld.com>:On Thu, Apr 20, 2017 at 3:17 AM, Stephane Ducasse <stepharo.self@gmail.com> wrote: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.��SteftestSelectEveryFirstself assert: (#(#Object #subclass: #Point #instanceVariableNames: 'x y' #classVariableNames: '' #package: 'Kernel-BasicObjects') selectEveryFirst) asArray equals: #(#Object #Point 'x y' ��'' 'Kernel-BasicObjects')selectEveryFirst seems a strange name, not indicating the skip amount. ��The first of every three? or four?�� As it stand, technically I'd think its result would��be equals: (#(#Object #subclass: #Point #instanceVariableNames: 'x y' #classVariableNames: '' #package: 'Kernel-BasicObjects')��+1 to Peter's suggested #withIndexSelect:cheers -benOn the other hand, we have #keysAndValuesDo: which competes with #withIndexDo: and is a bit more portable across dialects
(it's just that it turns the bloc parameters the other way around, [:index :element | ])So maybe this should have been #keysAndValuesSelect: #keysAndValuesCollect:Reminder, keys does not mean Dictionary, in an IndexedCollection (or maybe a SequenceableCollection) the keys are indices. Or the other way around, a Dictionary is indexed by arbitrary keys (not just positive integers).