[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Recursive Anonymous Functions
- From: gary ng <garyng2000@...>
- Date: Wed, 1 Aug 2007 19:27:34 -0700 (PDT)
Do you mean the Y combinator ?
--- Patrick Donnelly <email@example.com> wrote:
> I know this has been talked about before, and I read
> all the posts in the archive on this. There wasn't
> an "accepted" method for going about it, so I
> wondered if this implementation is optimal:function
> execute(func, ...) return func(...);end;function
> test(s) return execute(function(f) local fact;
> fact = function(n, ret) ret = ret or 1;
> if n == 0 then return 1 * ret end; return
> fact(n - 1, n * ret); end; return fact(f);
> end, s);end;test(3) --> 6Comments?-Patrick Donnelly
> "One of the lessons of history is that nothing is
> often a good thing to do and always a clever thing
> to say."
> -Will Durant
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.