Created
September 25, 2011 12:40
-
-
Save Dykam/1240571 to your computer and use it in GitHub Desktop.
Messing around with CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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