From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: replacing a certain element in a list with another Date: Tue, 30 Sep 2003 20:01:22 GMT Organization: Level(3) Communications, Woburn, MA Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <3F79A1AA.5040008@yahoo.com> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1064953409 10210 80.91.224.253 (30 Sep 2003 20:23:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 Sep 2003 20:23:29 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 30 22:23:27 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A4R1r-0007po-00 for ; Tue, 30 Sep 2003 22:23:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A4Qv9-0007jq-Gx for geh-help-gnu-emacs@m.gmane.org; Tue, 30 Sep 2003 16:16:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!crtntx1-snh1.gtei.net!news.gtei.net!news.level3.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 37 Original-NNTP-Posting-Host: 171.78.176.30 Original-X-Trace: news.level3.com 1064952082 171.78.176.30 (Tue, 30 Sep 2003 20:01:22 GMT) Original-NNTP-Posting-Date: Tue, 30 Sep 2003 20:01:22 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:116973 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12898 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12898 In article , Roland Winkler wrote: >Kind of a related question: > >The function `reverse' does not alter the original argument LIST. On >the other hand, `nreverse' reverses LIST by modifying cdr pointers. >Why does the docstring of `reverse' say > > See also the function `nreverse', which is used more often. One of the most common uses of reversing a list is part of the idiom for accumulating values during a loop, e.g. (let ((result nil)) (dotimes (i 10) (push i result)) (nreverse result)) Since this is a newly constructed list that has no other references to it, it's fine to reverse it destructively rather than waste space creating a new list. >Yet, the info page for `nreverse' says > > To avoid confusion, we usually store the result of `nreverse' back > in the same variable which held the original list: > >Wouldn't it then be more natural to use `reverse' from the >beginning? Or am I missing something here?? You have to do the assignment whether you use reverse or nreverse. -- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.