Created
June 14, 2014 07:17
-
-
Save miensol/367d27fb1b3f7966e31a to your computer and use it in GitHub Desktop.
es6 fibonaci generator
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
var fibo = function *(){ | |
var a = 0, | |
b = 1; | |
yield a; | |
yield b; | |
while(true){ | |
var next = a + b; | |
yield next; | |
a = b; | |
b = next; | |
} | |
}; | |
var fiboGenerator = fibo(); | |
var current = null; | |
while(!(current = fiboGenerator.next()).done){ | |
console.log(current.value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment