From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: tomas@fabula.de Newsgroups: gmane.lisp.guile.devel Subject: Re: make an element last element of a list Date: Wed, 22 Oct 2003 12:22:54 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <20031022102254.GA23380@www> References: <1066748921.28107.220.camel@MARZULLO-MIS> <20031021155009.GC18423@www> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1066818384 3712 80.91.224.253 (22 Oct 2003 10:26:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 22 Oct 2003 10:26:24 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Oct 22 12:26:22 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 1ACGC6-0004m5-00 for ; Wed, 22 Oct 2003 12:26:22 +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 1ACG9a-0003Vq-VV for guile-devel@m.gmane.org; Wed, 22 Oct 2003 06:23:46 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ACG9R-0003VH-Rk for guile-devel@gnu.org; Wed, 22 Oct 2003 06:23:37 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ACG8u-0003Qs-0M for guile-devel@gnu.org; Wed, 22 Oct 2003 06:23:35 -0400 Original-Received: from [217.22.192.104] (helo=www.elogos.de) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ACG8t-0003QO-7E for guile-devel@gnu.org; Wed, 22 Oct 2003 06:23:03 -0400 Original-Received: by www.elogos.de (Postfix, from userid 5002) id B82BA14078; Wed, 22 Oct 2003 12:22:54 +0200 (CEST) Original-To: guile-devel@gnu.org Content-Disposition: inline In-Reply-To: <20031021155009.GC18423@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:2917 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2917 On Tue, Oct 21, 2003 at 05:50:09PM +0200, rm@fabula.de wrote: > On Tue, Oct 21, 2003 at 05:08:42PM +0200, Laurent Marzullo wrote: > > Hello all, > > > > I've got a scheme list > > > > SCM scm_game_list; > > > > and I want to add, with C API, an elements at the end of > > the list. > > If you want to destrutively modify your list you can do the > following: > > (define my-lst (list 1 2 3 4)) > (define new-last (list 5)) > (set-cdr! (last my-lst) new-last) ...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