[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to do actual recursive functions in Lua?
- From: Romulo <romuloab@...>
- Date: Mon, 23 Mar 2009 12:05:23 -0300
I don't know if I got it correctly, but...
local function fact( n )
if n > 1 then return n * fact( n - 1 ) end
f = makereallyrecursive()
print( f( 6 ) )
On Mon, Mar 23, 2009 at 12:01 PM, David Kastrup <firstname.lastname@example.org> wrote:
> Ok, call me stupid, but a recursive function in my book would be one
> that can call itself and is self-contained.
> If I do something like
> function fact(n)
> if n>1 then
> return n*fact(n-1)
> return 1
> then this is _not_ a self-contained recursive function, since it relies
> on calling itself through the variable named fact. If I do
> this does not work. We had some previous discussion about recursive
> stuff here (with some fairly esoteric code partly), but what would most
> likely be the _simplest_ way to get a self-contained recursive function?
> David Kastrup