2 ms·
This will probably go unnoticed, but this function seems to be equivalent, at least for the factorial example. What's the difference? var Y = function(X) {
by tlrobinson 16y ago
This will probably go unnoticed, but this function seems to be equivalent, at least for the factorial example. What's the difference?
var Y = function(X) {
var Z = X(function(arg) {
return Z(arg);
});
return Z;
}
- ostso 16y agoThe difference is that the whole point of the Y combinator is that it's a fixed-point combinator that doesn't use explicit recursion. Imagine that you didn't have "var", and couldn't name anything (which is the situation in, say, the lambda calculus). Using the Y combinator you could still define recursive functions.