From: Barry Margolin
Subject: Re: nconc
Date: 
Message-ID: <5ukleu$h24@tools.bbnplanet.com>
In article <············@i2.com>,
Immanuel Litzroth  <·················@i2.com> wrote:
>(setq x nil)
>(nconc x '(3 4)) -> evaluates to (3 4)
>x evaluates to nil

(nconc list1 list2) modifies the cdr of the last cons in list1 so that it
points to list2.  But if list1 is NIL, there's no cdr to modify.

In neither case is X modified.  The modification occurs on the list that X
refers to, not X itself.

This is why you should always use destructive functions for value, not for
their side effects; the side effects are just an optimization.  You should
write:

(setq x (nconc x '(3 4)))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.