Path: csiph.com!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'languages,': 0.03; 'perl,': 0.05; 'subject:Python': 0.05; 'content- type:multipart/signed': 0.09; 'filename:fname piece:signature': 0.09; 'backwards.': 0.16; 'content-type:application/pgp- signature': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname:signature.asc': 0.16; 'reversed': 0.16; 'subject: \n ': 0.16; 'cc:addr:python-list': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; "aren't": 0.21; 'tells': 0.21; 'subject:list': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'code': 0.26; 'function': 0.27; 'cc:addr:gmail.com': 0.28; 'temporary': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'least': 0.30; 'pretty': 0.31; 'pure': 0.32; 'break': 0.32; 'list': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'lee': 0.34; 'rather': 0.34; 'function.': 0.34; 'occurs': 0.34; 'external': 0.35; 'list,': 0.36; 'cc:2**1': 0.36; 'page': 0.37; 'but': 0.37; 'using': 0.37; 'received:128': 0.38; 'received:192': 0.38; 'being': 0.40; 'view': 0.61; 'scheme.': 0.67; 'natural': 0.67; '29,': 0.73; 'fresh,': 0.84; 'idiom': 0.84; 'idiomatic': 0.84; 'xah': 0.84; 'subject:place': 0.91; 'subject:lang': 0.95 Date: Thu, 01 Mar 2012 00:07:21 -0600 From: Evan Driscoll User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Dan Stromberg Subject: Re: Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp References: <85fa5760-68c8-41a2-9116-2489165f7ca1@j5g2000yqm.googlegroups.com> In-Reply-To: X-Enigmail-Version: 1.3.5 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEA4BABAE2B566630D4143EAF" Cc: python-list@python.org, Xah Lee X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330582525 news.xs4all.nl 6962 [2001:888:2000:d::a6]:52763 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21078 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigEA4BABAE2B566630D4143EAF Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2/29/2012 23:05, Dan Stromberg wrote: >=20 > On Wed, Feb 29, 2012 at 8:07 PM, Xah Lee > wrote: >=20 > This page tells you what's =93In-place algorithm=94, using {python,= perl, > emacs lisp} code to illustrate. >=20 > Aren't in-place reversals rather non-functional? There is one place where they're reasonably idiomatic in Lispy languages, at least by my understanding. That occurs when you are writing a function that returns a list and there is a natural recursive way to build up the answer -- but backwards. The idiom then is to build up a temporary list up backwards, then call an in-place reversal function. (NREVERSE in Common Lisp. I thought there was a reverse! in Scheme, but apparently not.) This doesn't break the external view of a pure function because the list that's being reversed is a fresh, temporary list, which is why this idiom would even fit in pretty well in Scheme. Evan --------------enigEA4BABAE2B566630D4143EAF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPTxIgAAoJEAOzoR8eZTzglAUH/RB1S/HS/D3H8XGJg/S6ODiG HHov8G07iqd9Vl9qNMUVJ5yAFvaDWFjJZGx3jnOIesz64D6GLpDWdS+qhG5yjb3V UTMQ2cSKO0HHnien97s8EDrkklVqjWL91MSmN6aElTEBfppvUfl3ks9BKTuZGJXy VPzH9z1J1Dlc5fdsPvKcbk+5Sz67A8JGRF0R26K0Lzbv/tjfKmQTsKnMwobiuiFG UGlkzy4uyOQSrHcPVZbk8oWU/65cd69QsFOyT2KyAa8p4NEzWUYNe4kiSuCgc97r bT8N7CF7KbLN9/oo68wDYuL6z5mTrZae3WwnTD+9aEI8MvR6Xr5Fyy4q0rNBNRY= =kBlI -----END PGP SIGNATURE----- --------------enigEA4BABAE2B566630D4143EAF--