Hi

I was looking at how we can turn a collection into a stream.

I played with

g := Generator on: [ :gen |
    | current |
    current := 0.
    [ gen yield: (current := current + 1) ] repeat ].
g next.

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?

We can have a stream of blocks.

Stef









Reply via email to