• How does this factorial function work without recursion or loops
    4 replies, posted
[CODE]local fact = (function(f) return (function(x) return f(function(y) return x(x)(y) end) end)(function(x) return f(function(y) return x(x)(y) end ) end) end )(function(f) return function(x) return (x == 0 and 1 or (x*f(x-1)) ) end end) print(fact(4)) //24[/CODE] I really wonder how it works! pls halp
But it is sort of recursion, just in a different format.
but how is it possible to recurse when every function is anonymous and has no name. nameless functions can't call themselves
That's why there's two functions with the same contents.
[QUOTE=Chessnut;49431596]That's why there's two functions with the same contents.[/QUOTE] This techically isn't recursive by any formal means. ([I]Combinatorics[/I])
Sorry, you need to Log In to post a reply to this thread.