[Python-Dev] Proper tail recursion (original) (raw)
Christopher T King squirrel at WPI.EDU
Thu Jul 15 17:10:04 CEST 2004
- Previous message: [Python-Dev] Proper tail recursion
- Next message: [Python-Dev] Proper tail recursion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 15 Jul 2004, Andrew Koenig wrote:
[what I was trying to say, only better] :)
Just a note: because Python sticks an implicit 'return None' at the end of a function, rather than returning the result of the last expression, like Scheme, you have to have an explicit return to see any effect:
def traverse(t, f):
if t:
f(t)
traverse(t.left)
return traverse(t.right)
- Previous message: [Python-Dev] Proper tail recursion
- Next message: [Python-Dev] Proper tail recursion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]