bounces

0.0.1 • Public • Published

Trampoline

Reifies continutations onto the heap, rather than the stack. Allows efficient tail calls.

Example usage:

function loop(n) {
   function inner(i) {
       if(== n) return done(n);
       return cont(function() {
           return inner(+ 1);
       });
   }
 
   return trampoline(inner(0));
}

Where loop is the identity function for positive numbers. Without trampolining, this function would take n stack frames.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    5

Package Sidebar

Install

npm i bounces

Weekly Downloads

5

Version

0.0.1

License

MIT

Last publish

Collaborators

  • stickupkid