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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <random832@fastmail.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'received:internal': 0.09; 'rewrite': 0.09; 'subject:while': 0.09; 'python': 0.11; 'iteration': 0.16; 'loops': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'reedy': 0.16; 'subject:recursion': 0.16; 'language': 0.16; 'wrote:': 0.18; 'programming': 0.22; 'saying': 0.22; 'header:In- Reply-To:1': 0.27; 'ones.': 0.31; 'styles': 0.31; 'received:66': 0.35; 'but': 0.35; 'really': 0.36; 'should': 0.36; 'two': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'easy': 0.60; 'is.': 0.60; 'from:no real name:2**0': 0.61; 'header :Message-Id:1': 0.63; 'here': 0.66; 'secret': 0.74; '2013,': 0.91; 'steps.': 0.91
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= 5dQYGSmIVdoGt/m5S7qr8EaZTJk=; b=Lgat5MJupl2hMVez/4ZYqFnjxAcxEX6B KaehrmBTnUOeTLRbi0AeFdDTiaDhqdVGxq5FD45ffSEQlFrnPUX+6EJOYdAlhwzr okxHkYsQA12NqWNv/1qZq5+tFMjlwWaFHNPPe/AiDV+VRM0i12lykFuiEr5R1LZE SItjLdPuoAU=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=5dQYGSmIVdoGt/m5S7qr8EaZTJk=; b=btg 1CWsuLsY2TaRLcsHoi7iIPaxriGax24n1LVF3BL6eSqAcaA6azytXSyzjCOYdFXi +cWGSHaZ5RohpvMpBa7rpxnWLjwl8GjPowokLg7udvsqmj67LJunEedPu3rCpFJY JlEHuBri41+ei1v8IVWYQMGknXUGT9M6DYR3flRE=
X-Sasl-Enc Y/iSF44eVM/17AQgjyI4UlViNmVEdT02rrNOZ6yLlEO9 1380717085
From random832@fastmail.us
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-ce174988
In-Reply-To <l2feu0$n61$1@ger.gmane.org>
References <l2feu0$n61$1@ger.gmane.org>
Subject Re: Tail recursion to while iteration in 2 easy steps
Date Wed, 02 Oct 2013 08:31:25 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.619.1380717089.18130.python-list@python.org> (permalink)
Lines 9
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380717089 news.xs4all.nl 15922 [2001:888:2000:d::a6]:55665
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55319

Show key headers only | 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