[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Thought experiment: what would you remove from Lua
- From: Sean Conner <sean@...>
- Date: Sun, 9 Sep 2018 21:24:03 -0400
It was thus said that the Great Sam Pagenkopf once stated:
> The recursive definitions are something I didn't consider. If you were to
> enable recursion in local function assignments. it would be strange because
> it violates scoping rules.
Nope, not with the Y-combinator:
local fact = Y(function(self,n)
if n == 0 then
return 1
else
return n * self(n - 1)
end
end)
print(fact(5))
Now the trick is to define Y().
-spc