Forum: Ruby A stream implementation for Ruby

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2009-01-17 00:07
(Received via mailing list)
Hi all

Streams are lazily evaluated lists. I have been inspired by James'
excellent blog about infinite streams, and the functional  interface
of Scheme towards their usage.
But just in order to keep this short I have put all the links to the
release, documentation and other sources on the Labrador Rubyforge

753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-01-19 10:05
Robert Dober wrote:
> Streams are lazily evaluated lists.

Aside: it is also possible to make use of infinite enumerators in Ruby
(i.e. a traditional 'each' method which yields an infinite number of
values), and this may be sufficient in some applications.

In order for this to be useful, you need to process chains of methods
acting 'horizontally' instead of 'vertically'. The block form of
Enumerator lets this be done natively in ruby 1.9:

and with a little work, this can be made entirely transparent to map,
select etc:

It turns out to be very easy to implement the block form of Enumerator
in ruby 1.8. I contributed an implementation of this to the Facets

Anyway, I just thought this was worth a mention. It's not as powerful as
full lazy evaluation, although if you combine this with Generators I
think it gets pretty close.


This topic is locked and can not be replied to.