[Ann Lab419::functional] A stream implementation for Ruby

Discussion in 'Ruby' started by Robert Dober, Jan 16, 2009.

  1. Robert Dober

    Robert Dober Guest

    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
    Homepage.
    http://labrador.rubyforge.org/index.html

    Enjoy.
    Robert
    --
    It is change, continuing change, inevitable change, that is the
    dominant factor in society today. No sensible decision can be made any
    longer without taking into account not only the world as it is, but
    the world as it will be ... ~ Isaac Asimov
     
    Robert Dober, Jan 16, 2009
    #1
    1. Advertising

  2. Re: A stream implementation for Ruby

    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:
    http://redmine.ruby-lang.org/issues/show/707

    and with a little work, this can be made entirely transparent to map,
    select etc:
    http://redmine.ruby-lang.org/issues/show/708

    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
    project:

    http://facets.rubyforge.org/git?p=facets.git;a=blob_plain;f=lib/lore/facets/enumerator.rb;hb=HEAD
    http://facets.rubyforge.org/git?p=facets.git;a=blob_plain;f=lib/more/facets/filter.rb;hb=HEAD

    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.

    Regards,

    Brian.
    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Jan 19, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rasmusson, Lars
    Replies:
    1
    Views:
    772
    popov
    Apr 30, 2004
  2. Replies:
    9
    Views:
    654
    Alex Buell
    Apr 27, 2006
  3. Alexander Korsunsky

    get stream mode flags from an opened stream

    Alexander Korsunsky, Feb 17, 2007, in forum: C++
    Replies:
    1
    Views:
    464
    John Harrison
    Feb 17, 2007
  4. dolphin
    Replies:
    6
    Views:
    570
    Thomas Fritsch
    Mar 18, 2007
  5. Robert Dober
    Replies:
    12
    Views:
    181
    Christopher Dicely
    Apr 19, 2009
Loading...

Share This Page