Skip to content

Instantly share code, notes, and snippets.

@kaosf
Created November 29, 2014 16:14
Show Gist options
  • Select an option

  • Save kaosf/a39643b363e1fdd7d7fe to your computer and use it in GitHub Desktop.

Select an option

Save kaosf/a39643b363e1fdd7d7fe to your computer and use it in GitHub Desktop.
# ref. http://stackoverflow.com/questions/3392813/how-can-i-get-a-lazy-array-in-ruby
fib = Enumerator.new { |y|
a = b = 1
loop {
y << a
a, b = b, a + b
}
}
p fib.take(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment