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

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to