Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55319

Re: Tail recursion to while iteration in 2 easy steps

From random832@fastmail.us
References <l2feu0$n61$1@ger.gmane.org>
Subject Re: Tail recursion to while iteration in 2 easy steps
Date 2013-10-02 08:31 -0400
Newsgroups comp.lang.python
Message-ID <mailman.619.1380717089.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Oct 1, 2013, at 17:30, Terry Reedy wrote:
> Part of the reason that Python does not do tail call optimization is 
> that turning tail recursion into while iteration is almost trivial, once 
> you know the secret of the two easy steps. Here it is.

That should be a reason it _does_ do it - saying people should rewrite
their functions with loops means declaring that Python is not really a
multi-paradigm programming language but rather rejects functional
programming styles in favor of imperative ones.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-02 08:31 -0400
  Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-02 13:32 +0000
    Re: Tail recursion to while iteration in 2 easy steps random832@fastmail.us - 2013-10-02 10:04 -0400
      Re: Tail recursion to while iteration in 2 easy steps Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-02 19:13 +0000

csiph-web