A new module for performing tail-call elimination
Robin Becker
robin at reportlab.com
Thu Jul 16 05:13:29 EDT 2015
On 16/07/2015 09:07, Steven D'Aprano wrote:
.........
> Fixing the obvious mistake (failing to return anything) leads to the next
> mistake. When all you have is a hammer, everything looks like a nail.
>
> def even(n):
> return n%2 == 0
>
> def odd(n):
> return n%2 != 0
>
......
what about
>>> def odd(n):
... return bool(n%2)
...
>>> def even(n):
... return not odd(n)
...
not much more complex, but the logic for A(n) and not A(n) is only done once.
Not really much to do with TCO though.
--
Robin Becker
More information about the Python-list
mailing list