Is something like #collect:until: exist?
Mathieu
mathk.sue at gmail.com
Sun Oct 29 07:33:09 UTC 2006
Bill Schwab a écrit :
> Is this what you had in mind?
>
> collect: aBlock until:quitBlock
> "Evaluate aBlock with each of the receiver's elements as the
> argument.
> Stop when quitBlock evaluates to true.
> Collect the resulting values into a collection like the
> receiver. Answer
> the new collection."
>
> | newCollection |
> newCollection := self species new.
> self do: [:each |
> ( quitBlock value:each )
> ifFalse:[
> newCollection add: (aBlock value: each)
> ]
> ifTrue:[
> ^newCollection.
> ].
> ].
> ^ newCollection.
>
>
> You might first look at #select:thenCollect: to see if it meets your
> needs. The "until" is a little stream-like, so you might also consider
> moving items from a read stream to a write stream on a new collection
> and then collect from it.
>
> Bill
>
Yes it's what mean your script I was just wanted to know if it was already in the image.
And it's also to manipulate a stream.
Thanks
>
>
>
> Wilhelm K. Schwab, Ph.D.
> University of Florida
> Department of Anesthesiology
> PO Box 100254
> Gainesville, FL 32610-0254
>
> Email: bills at anest4.anest.ufl.edu
> Tel: (352) 846-1285
> FAX: (352) 392-7029
>
>
>
More information about the Squeak-dev
mailing list
|