This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: bug in append!
- To: Ivan Toshkov <ivant at intransco dot com>
- Subject: Re: bug in append!
- From: Roland Orre <orre at nada dot kth dot se>
- Date: Mon, 18 Oct 1999 14:16:55 +0200 (MET DST)
- CC: guile at sourceware dot cygnus dot com
- Reply-to: orre at nada dot kth dot se (Roland Orre)
Ivan Toshkov <ivant@intransco.com> wrote:
>> On Mon, Oct 18, 1999 at 01:39:28PM +0200, Roland Orre wrote:
>...
>> in the list. To be safe you have to
>> (set! a (append! a '(b)))
Ivan:
> maybe you mean (set! a (append a '(b))) ?
> yes, that works and that's the way I rewrote it..
No, I mean
(set! a (append! a '(b)))
The essential thing with append! is that it does not copy the lists,
it destructively changes all last pairs of all lists being appended
except the last one.
When you use append! it is normally of performance reasons. It uses
no extra memory and is thus also faster.
(set! a (append! a '(b)))
When you develop things it is always a good rule to use e.g
(set! a (append a '(b)))
and when everything works you can change some of the append to append!
to possibly speed up things.
Best regards
Roland