lambda expressions

Gerson Kurz gerson.kurz at t-online.de
Mon Feb 4 10:55:58 CET 2002


On Sun, 3 Feb 2002 11:04:57 -0600, "Jason Orendorff"
<jason at jorendorff.com> wrote:

>Gerson Kurz writes:
>> So, I see few limitations in the current implementation of lambda for
>> the DEDICATED lambda-user.
>
>Lack of tail recursion could be a problem.

I'm not really sure - I left university six years ago -, but isn't

WHILE = lambda x,y: BOOL(x()) and (FALSE(y()) or WHILE(x,y))

tail recursive? Its not optimized - that is, the recursion needs
stack, but it seems to fit the general definition:

"""Tail Recursion
==============
A call is tail-recursive if nothing has to be done after the the call
returns, i.e. when the call returns, the returned value is immediately
returned from the calling function.  In this example, the recursive
call to `myfun' is tail-recursive:
     
     (defun myfun (x)
       (if (oddp (random x))
           (isqrt x)
           (myfun (1- x))))
"""

(Quoted from
http://www.cis.ksu.edu/VirtualHelp/Info/develop/cmu-user.info.Tail_Recursion.html)

Bye, Gerson
http://p-nand-q.com



More information about the Python-list mailing list