Skip to content

Instantly share code, notes, and snippets.

@Dykam
Created September 25, 2011 12:40
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 Dykam/1240571 to your computer and use it in GitHub Desktop.
Save Dykam/1240571 to your computer and use it in GitHub Desktop.
Messing around with CoffeeScript
fib = (n) ->
next = 1
current: 0
movenext: ->
if n-- is 0
@movenext = -> false
return false
[@current, next] = [next, @current + next]
true
fibTo10 = fib 10
while fibTo10.movenext()
console.log fibTo10.current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment