Skip to content
/ thunk.js Public

A generator for trampoline-evaluated recursive algorithms.

Notifications You must be signed in to change notification settings

jneen/thunk.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thunk

Usage:

var thunk = require('thunk');

var factorial = thunk.makeTrampoline(function(recurse) {
  return function(cc, n) {
    if (n <= 1) return cc(1);

    return recurse(function(result) { return cc(n * result) }, n - 1);
  };
});

factorial(5) // 120, with a constant stack size.  Aww, yiss.

About

A generator for trampoline-evaluated recursive algorithms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published