Ruby Arrays dynamically expand as needed.  You can apply blocks to them to
return things like even numbers.

array = []
array.size # => 0
array[0] # => nil
array[9999] # => nil
array << 1
array.size # => 1
array << 2 << 3 << 4
array.size # => 4

array = (0..9).to_a
array.select do |e|
  e % 2 == 0
end

# => [0,2,4,6,8]

Does this help?

On Sun, Aug 1, 2010 at 17:45, Andrew Wagner <wagner.andrew / gmail.com> wrote:

> How can I get a lazy array in Ruby? E.g., in Haskell, I can talk about
> [1..], which is an infinite list, lazily generated as needed. I can also do
> things like "iterate (+2) 0", which applies whatever function I give it to
> generate a lazy list. In this case, it would give me all even numbers.
> Anyway, I'm sure I can do such things in Ruby, but can't seem to work out
> how.
>