Subject : Re: Thought experiment: what would you remove from Lua

: From : Roberto Ierusalimschy <roberto@...>

: Roberto Ierusalimschy <roberto@...> Date: Tue, 11 Sep 2018 17:14:31 -0300

> local function Y(f) > local function g(...) return f(g, ...) end > return g > end > > print(Y(function(fac, n) if n <= 1 then return 1 else return n*fac(n-1) end > end)(10)) > > > There's a more complicated version of Y that does not require an assignment > (local function g(...) is really local g; g = function(...)) The problem here is not the assignment per se, but the fact that 'g' is recursive, so it only moves the recursion from one place to another. The following version does not use recursion (although this particular one is usually called Z, not Y): local Y = function (le) local a = function (f) return le(function (...) return f(f)(...) end) end return a(a) end -- Roberto