Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example of function in Trampolines in JavaScript doesn't work #51

Open
cachaito opened this issue Jul 7, 2015 · 0 comments
Open

example of function in Trampolines in JavaScript doesn't work #51

cachaito opened this issue Jul 7, 2015 · 0 comments

Comments

@cachaito
Copy link

cachaito commented Jul 7, 2015

In this example there is a Uncaught ReferenceError: trampoline is not defined

function factorial (n) {
  var _factorial = trampoline( function myself (acc, n) {
    return n
    ? function () { return myself(acc * n, n - 1); }
    : acc
  });

  return _factorial(1, n);
}

factorial(10);
  //=> 362800
factorial(32768);
  //=> Infinity
@cachaito cachaito changed the title example of function in Trampolines in JavaScript doesn't work example of function in Trampolines inside JavaScript doesn't work Jul 7, 2015
@cachaito cachaito changed the title example of function in Trampolines inside JavaScript doesn't work example of function in Trampolines in JavaScript doesn't work Jul 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant