|
KHMan wrote:
One can use Y Combinator to implement recursion using only anonymous functions.From the little I know or understand of lambda calculus, it's about anonymous functions.
local function Y(f) function rec(...) return f(rec, ...) end return rec endlocal fac = Y(function(fac, n) if n == 1 then return 1 else return fac(n - 1) * n end end)
In fact one can turn Y in purely anonymous function. It is expensive, but possible. See Wikipedia or some good old book (e.g. Essentials of Programming Languages) for more details.
-- e.v.e