Skip to content

Instantly share code, notes, and snippets.

@shouichi
Created December 17, 2013 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shouichi/7999529 to your computer and use it in GitHub Desktop.
Save shouichi/7999529 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def fibgen
prev, curr = 0, 1
lambda do
temp = prev
prev = curr
curr += temp
temp
end
end
fib = fibgen
10.times { p fib.call }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment