UNPKG

continuation.js

Version:

A module for tail call optimization by Continuation Passing Style (CPS) transformation with trampoline technique for Node.js

13 lines (11 loc) 194 B
function fact(x) { function fact_tail(x, r) { if (x === 0) { return r; } else { return fact_tail(x - 1, x * r); } } return fact_tail(x, 1); } exports.fact = fact;