The Y combinator in Javascript
matt.might.net
The Y combinator in Javascript
1–10 of 22 posts
Re: The Y combinator in Javascript
#2Re: The Y combinator in Javascript
#3Re: The Y combinator in Javascript
#4There's actually a simpler fixed-point combinator for JavaScript than the 'standard Y' - see http://rosettacode.org/wiki/Y_combinator#JavaScript
Re: The Y combinator in Javascript
#5Re: The Y combinator in Javascript
#6Curiously enough, the JavaScript Y combinator is in the Firefox source and has been since at least 2007: http://hg.mozilla.org/mozilla-central/file/fc78ee766770/js/s...
Re: The Y combinator in Javascript
#7Curiously enough, the JavaScript Y combinator is in the Firefox source and has been since at least 2007: http://hg.mozilla.org/mozilla-central/file/fc78ee766770/js/s...
Re: The Y combinator in Javascript
#8Curiously enough, the JavaScript Y combinator is in the Firefox source and has been since at least 2007: http://hg.mozilla.org/mozilla-central/file/fc78ee766770/js/s...
That is by far the clearest implementation of the Y-combinator I've ever seen. And I'm not even a JavaScript programmer.
function Y(f) {
var g = f(function(arg) {
return g(arg);
});
return g;
}
The inner() function from Mozilla's implementation is actually unnecessary in languages that support lexical closures.Re: The Y combinator in Javascript
#9which still smells like recursion, a type of recursion where the recursive element keeps getting punted around as a parameter like an epileptic cannibalistic stem-cell with no name.