[squeak-dev] Collections/Streams | About enumerating a sequence up to a matching query ...
Jaromir Matas
m at jaromir.net
Mon Mar 8 12:33:13 UTC 2021
How about this, using valueWithExit again (still long but a bit more
readable):
| result supplier |
supplier := (1 to: 100) readStream.
result := OrderedCollection new.
[:exitBlock |
[supplier atEnd]
whileFalse: [ | value |
value := supplier next.
value even ifTrue: [result add: value squared].
value squared = 2500 ifTrue: [exitBlock value]]
] valueWithExit.
result
-----
^[^ Jaromir
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html
More information about the Squeak-dev
mailing list
|