From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: rm@fabula.de Newsgroups: gmane.lisp.guile.devel Subject: Re: make an element last element of a list Date: Wed, 22 Oct 2003 12:40:31 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <20031022104031.GA22986@www> References: <1066748921.28107.220.camel@MARZULLO-MIS> <20031021155009.GC18423@www> <20031022102254.GA23380@www> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1066820201 15103 80.91.224.253 (22 Oct 2003 10:56:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 22 Oct 2003 10:56:41 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Oct 22 12:56:39 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 1ACGfP-0006GW-00 for ; Wed, 22 Oct 2003 12:56:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ACGYs-0001zg-Ew for guile-devel@m.gmane.org; Wed, 22 Oct 2003 06:49:54 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ACGQN-0000qJ-8z for guile-devel@gnu.org; Wed, 22 Oct 2003 06:41:07 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ACGPq-0000lI-9o for guile-devel@gnu.org; Wed, 22 Oct 2003 06:41:05 -0400 Original-Received: from [217.22.192.104] (helo=www.elogos.de) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ACGPp-0000kx-3R for guile-devel@gnu.org; Wed, 22 Oct 2003 06:40:33 -0400 Original-Received: by www.elogos.de (Postfix, from userid 5001) id D711014078; Wed, 22 Oct 2003 12:40:31 +0200 (CEST) Original-To: tomas@fabula.de Content-Disposition: inline In-Reply-To: <20031022102254.GA23380@www> User-Agent: Mutt/1.5.3i X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2918 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2918 > > (define my-lst (list 1 2 3 4)) > > (define new-last (list 5)) > > (set-cdr! (last my-lst) new-last) ^^^^ Sorry, typo, should be (last-pair ....) RalfD > ...but you don't want to do this if the lists grow too large. > Keeping track of the last cons cell resp. maintaining a > reversed list (and reversing it once at the end, if ever > necessary) as another poster suggested is more efficient. > For short lists the solution is short and sweet, though. > > Don't hesitate to ask if you need examples. > > Cheers > -- tomas > > > _______________________________________________ > Guile-devel mailing list > Guile-devel@gnu.org > http://mail.gnu.org/mailman/listinfo/guile-devel _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel