Iterative vs. Recursive coding
raoulbia at gmail.com
Sat Aug 21 11:35:18 CEST 2010
On Aug 21, 7:37 am, John Nagle <na... at animats.com> wrote:
> On 8/20/2010 1:17 PM, John Bokma wrote:
> > I think you mean tail recursion optimization / elimination.
> > Python does tail recursion:
> Not very well.
> def cnt(n) :
> if n > 0 :
I'm intrigued by this example. Is there something missing in the code?
When i run it i get: <function cnt at 0x02B2FE70>
I suppose it is meant to print a sequence of numbers from n down to
re tail recursion, on wiki i found:
"With tail recursion, there is no need to remember the place we are
calling from—instead, we can leave the stack alone, and the newly
called function will return its result directly to the original
caller. Converting a call to a branch or jump in such a case is called
a tail call optimization. "
not sure i understand that...
is this bit of theory applicable to your cnt function above?
More information about the Python-list