[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Self-awareness of functions?
- From: Steve Litt <slitt@...>
- Date: Thu, 30 Dec 2010 01:22:34 -0500
On Thursday 30 December 2010 00:44:22 Henk Boom wrote:
> function recursify(f)
> local function g(...)
> return f(g, ...)
> end
> return g
> end
>
> fact = recursify(function (self, n)
> if n == 1 then
> return 1
> else
> return n * self(n-1)
> end
> end)
One of the seven wonders of the world is that Lua actually makes that work. I
can almost, but not quite wrap my head around it. Tomorrow's another day.
Henk -- by what mental process did you devise this solution?
Thanks,
SteveT
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt