lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> -------- Original Message --------
> Date: Thu, 30 Dec 2010 23:27:35 +0200
> From: Dirk Laurie <dpl@sun.ac.za>
> Subject: Re: Self-awareness of functions?
> To: Lua mailing list <lua-l@lists.lua.org>
> Message-ID: <20101230212735.GC6428@rondloper>
> Content-Type: text/plain; charset=us-ascii
> 
> On Thu, Dec 30, 2010 at 10:37:41PM +0200, jgiors@threeeyessoftware.com wrote:
> > What Steve wrote had a typo (missing keyword "then"), but was 
> > otherwise correct. It should have been this:
> > 
> > local fact
> > function fact(n)
> >     if n == 2 then return 2 else return n*fact(n-1) end
> > end
> > 
> Alas, no.  Try that code for n=0 and n=1.

Yes, I had noticed that, but didn't think it worth mentioning given the
topic of local recursive functions.

> The rest of your post deals with things that others have already
> responded to.
> 
> Dirk

I reviewed the posts in the archive and see that your initial example
has the do...end wrap (to make it work in the console). I had forgotten
it and misinterpreted your reply to Steve.

John Giors
Independent Programmer
Three Eyes Software
jgiors@ThreeEyesSoftware.com
http://ThreeEyesSoftware.com