Bill Clementson's Blog: JavaScript and Lisp
bc.tech.coop
bc.tech.coop
function Y(X)
(function(procedure)
X(function(arg) procedure(procedure)(arg)))
(function(procedure)
X(function(arg) procedure(procedure)(arg)))https://developer.mozilla.org/En/Core_JavaScript_1.5_Referen...
Example of anonymous recursive function with arguments.callee:
var factorial=function(n) {
return (!(n>1))? 1 : arguments.callee(n-1)*n;
}
Example of anonymous recursive function without arguments.callee: var factorial=function factorial(n) {
return (!(n>1))? 1 : factorial(n-1)*n;
}Result in Firefox: "Too much recursion"
I'm still surprised I didn't flunk B521 when Dan Friedman put something like this in my Java implementation of a Scheme interpreter and it blew up after some finite number of iterations.
It might have worked if method calls were properly tail-recursive!
i would have thought you could say that about functions in any language...