Recursively traverse linked list -- help!
phr-n2002a at nightsong.com
Thu Feb 21 00:37:18 CET 2002
"Jason Orendorff" <jason at jorendorff.com> writes:
> > > def f(val):
> > > global f
> > > f = val and f1 or f2
> > > return f(val)
> > This is not tail recursion. The "global f" declaration shadows
> > the "f" that names the function.
> That's not true. The f that names the function is global anyway.
> It's the assignment that causes the problem.
Oh yes, you're correct. However, the tail call should still be
optimized, compiled as an indirect jump to f.
More information about the Python-list