RAA - lazylist/0.2.1

lazylist / 0.2.1

Short description: Implementation of lazy lists for Ruby
Category: Library/Datastructure
Status: beta
Created: 2003-12-09 15:26:00 GMT
Last update: 2005-12-21 23:17:06 GMT
Owner: Florian Frank (Projects of this owner)
Homepage: http://lazylist.rubyforge.org
Download: http://rubyforge.org/frs/download.php/7669/lazylist-0.2.1.tgz
License: GPL
Dependency:
None
Description:

This class implements lazy lists (or streams) for Ruby. Such lists avoid the computation of values which aren’t needed for some computation. So it’s possible to define infinite lists with a limited amount of memory. A value that hasn’t been used yet is calculated on the fly and saved into the list. A value which is used for a second time is computed only once and just read out of memory for the second usage.

Here is a little example that shows how to define the
Fibonacci sequence as a lazy list:

fib = LazyList.tabulate(0) { |x| x < 2 ? 1 : fib[x-2] +
fib[x-1] } # => [1,... ]
fib[5] # => 8
fib # => [1, 1, 2, 3, 5, 8,... ]

Versions: [0.3.2 (2009-07-25)] [0.3.1 (2007-11-27)] [0.3.0 (2007-05-05)] [0.2.2 (2005-12-23)] [0.2.1 (2005-12-21)] [0.2.0 (2005-10-08)] [0.1.3 (2005-10-01)] [0.1.2 (2004-10-02)] [0.1.1 (2004-06-14)]

Edit this project (for project owner)

back to RAA top