Re:The Y Combinator in Arc and Java
by caustic on Monday March 02, 2009 @02:40PM
(#500515)
Y combinator in JavaScript: http://thraxil.org/users/anders/posts/2008/09/15/My-Own-Java...
[ Parent
| on HN ]
I'm not very literate in functional programming ... so excuse such a dumb question. But I'm curious why you write the recursing function duplicated? eg. isn't this version of your code equivalent?
function Y(X) {
var fn = function(procedure) {
return X(function(arg) {
return procedure(procedure)(arg);
});
};
return fn(fn);
}
Or am I missing something vital here about how it is all working? The shorter version seems clearer to me (not that any of this is clear to me), and functionally equivalent.