Created
December 23, 2015 21:32
-
-
Save tlkahn/1059a8279bb528d3ad92 to your computer and use it in GitHub Desktop.
recursive es6 generator
This file contains hidden or 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 gen = function *(count){ | |
console.log("gen called: ", count); | |
if (count < 20) | |
yield count; | |
else | |
yield *gen(count/2); | |
} | |
var g = gen(100); | |
do { | |
var n = g.next(); | |
console.log("val: ", n.value); | |
} while (!n.done) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment