[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: How to do actual recursive functions in Lua?**
**From**: Roberto Ierusalimschy <roberto@...>
**Date**: Mon, 23 Mar 2009 12:13:09 -0300

> Ok, call me stupid, but a recursive function in my book would be one
> that can call itself and is self-contained.
>
> [...] this is _not_ a self-contained recursive function [...] to get a
> self-contained recursive function?
If a recursive function should be self contained, why do you need to
write "self-contained recursive function"? ;)
Anyway, I guess the _simplest_ way to get a *self-contained* recursive
function is this:
local function fact(n)
if n>1 then
return n*fact(n-1)
end
return 1
end
-- Roberto