2016-09-29 6:54 GMT+02:00 stepharo <stepharo@free.fr>:
and now imagine that we have

(1 to: 1000) collect: [:each | {each -1 . each . each + 1}].

I was wondering how we could turn it into a stream

(1 to: 1000) asStream collect: [:each | {each -1 . each . each + 1}].

and what would be the asStream method.

for index based I can see that next

next is something like

next

�� �� ^ self at: (current := current + 1)

and collect: could be rewritten to use a generator.

Now does anybody play with this already?

Does xtream provide a way to do something in the same vein?

Yes. XStream supports it:

(1 to: 1000) reading transforming: [:in :out | | each | each := in get. out ��put: each -1; put: each; put: each + 1]��