New tail recursion decorator

Casey Hawthorne caseyhHAMMER_TIME at istar.ca
Fri May 12 16:31:06 EDT 2006


Your examples are not tail recursive because an extra step is needed
before returning from the function call and that step cannot be thrown
away!

Alexander Schmolck <a.schmolck at gmail.com> wrote:

>def even(n):
>    return n == 0 or not odd(n-1)
>
>def odd(n):
>    return n == 1 or not even(n-1)
>

--
Regards,
Casey



More information about the Python-list mailing list