[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to do actual recursive functions in Lua?
- From: "Alex Davies" <alex.mania@...>
- Date: Tue, 24 Mar 2009 00:10:06 +0900
Or possibly simpler:
local function _fact(n)
if n > 1 then return n * _fact( n - 1 ) end
fact = _fact
On Mon, Mar 23, 2009 at 12:01 PM, David Kastrup <email@example.com> 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
if n>1 then
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?