Skip to content

Instantly share code, notes, and snippets.

@d11wtq
Created December 5, 2011 13:33
Show Gist options
  • Save d11wtq/1433594 to your computer and use it in GitHub Desktop.
Save d11wtq/1433594 to your computer and use it in GitHub Desktop.
; Returns a lambda, which for each invocation gives the next Fibbonnaci number
fib := { a := 0
b := 1
{ n := a
c := a + b
a = b
b = c
n } }
seq := fib:
seq:
; => 0
seq:
; => 1
seq:
; => 1
seq:
; => 2
seq:
; => 3
seq:
; => 5
seq:
; => 8
seq:
; => 13
; .. etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment