Just a quick thought:

select: selectBlock thenCollect: collectBlock

��� | newCollection |
��� newCollection := self species new.
��� self do: [:each | (selectBlock value: each) ifTrue: [newCollection add: (collectBlock value: each)]].
��� ^newCollection

But, we can not say that is going to be faster always... if newCollection grows too much, it could be slower. Also it wont work on SortedCollection becuase SortedCollection has to return an OrderCollection and species returns a SortedCollection... I did not see test for this message, it would be great to have them and try :-)

On Wed, Jul 15, 2009 at 5:01 PM, St�phane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi all

apparently

Collection>>select: selectBlock thenCollect: collectBlock
� � � �"Utility method to improve readability."

� � � �^ (self select: selectBlock) collect: collectBlock

so it would be good to avoid to do two passes on the same collection.
Any takers?

Stef


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project