Earlier quoted context omitted.
> Heh... completely wrong, but I suppose it's the best you can expect a non-techie/math nerd readership to get. Heck, it's probably close to the most you can expect the average programmer to get. How would you explain the Y Combinator to the Hacker News readership?
The Y combinator is a programming construct allowing one to write recursive functions without explicitly calling themselves (unnamed recursive functions): (define Y (lambda (X) ((lambda (procedure) (X (lambda (arg) ((procedure procedure) arg)))) (lambda (procedure) (X (lambda (arg) ((procedure procedure) arg))))))) (define F* (lambda (func-arg) (lambda (n) (if (zero? n) 1 (* n (func-arg (- n 1))))))) (define fact (Y…
// (define Y
// (lambda (X)
// ((lambda (procedure)
// (X (lambda (arg) ((procedure procedure) arg))))
// (lambda (procedure)
// (X (lambda (arg) ((procedure procedure) arg)))))))
var Y = function(X) {
return (function (procedure) {
return X(function (arg) {
return procedure(procedure)(arg);
});
})(function (procedure) {
return X(function (arg) {
return procedure(procedure)(arg);
});
});
}
// (define F*
// (lambda (func-arg)
// (lambda (n)
// (if (zero? n)
// 1
// (* n (func-arg (- n 1)))))))
var F = function(func_arg) {
return function(n) {
if (n === 0)
return 1;
else
return n * func_arg(n - 1);
};
}
// (define fact (Y F*))
var fact = Y(F);
// (write (fact 8))
console.log(fact(8));