[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make an element last element of a list
From: |
rm |
Subject: |
Re: make an element last element of a list |
Date: |
Wed, 22 Oct 2003 12:40:31 +0200 |
User-agent: |
Mutt/1.5.3i |
> > (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
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-devel