Skip to content

Instantly share code, notes, and snippets.

@jooyunghan
Created December 2, 2016 02:36
Show Gist options
  • Save jooyunghan/aeb61f43c03b3c90c4eae3d7118ee10b to your computer and use it in GitHub Desktop.
Save jooyunghan/aeb61f43c03b3c90c4eae3d7118ee10b to your computer and use it in GitHub Desktop.
function fibo2() {
var a, b; // local vars
return wrap(function (c) {
while (1) {
switch (c.next) {
case 0:
a=0, b=1;
case 1: // while begin
if (!true) { // while cond
c.next = 3;
break;
}
// while body ben
// yield a
c.next = 2;
return a;
case 2:
b = a + b;
a = b - a;
// while body end
c.next = 1;
break;
case 3:
// while end
case "end":
return c.stop();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment