UNPKG

tco

Version:

Tail call optimization in Node

22 lines (13 loc) 402 B
var tf = function () { var nf = tf.tco, na = arguments, next = true; while (1) { var r = nf.apply(null, na); nf = r[0].tco; na = r[1]; } }; tf.tco = function (i) { console.log(i); return [tf, [i+1]]; }; tf(1);