var sum = function (f) { return function (n) { return n === 1 ? 1 : n + f(n - 1); }; }; var s4 = function (h) { return sum(function (n) { return h(h)(n); }); }; console.assert(s4(s4)(5) === 15);