From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.bredband.com!bredband!uio.no!nntp.uio.no!ifi.uio.no!not-for-mail From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: Simple newbie list processing troubble Date: 30 Sep 2002 18:50:57 +0000 Organization: Naggum Software, Oslo, Norway Lines: 23 Message-ID: <3242400657742787@naggum.no> References: <10b28c6c.0209280104.52056c24@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: maud.ifi.uio.no 1033411858 18445 129.240.65.5 (30 Sep 2002 18:50:58 GMT) X-Complaints-To: abuse@ifi.uio.no NNTP-Posting-Date: 30 Sep 2002 18:50:58 GMT Mail-Copies-To: never User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.lisp:42547 * Peder Y | (defun foo (lst) | (loop for x in lst do | (setf (car x) 'A))) * Marco Antoniotti | The above will not necessarily work because you are changing the list as you | are traversing it. This is specifically mentioned in the language standard. Huh? The only way the above code would work is by changing the car of each cons cell that is the car of the cons cells that are traversed. This is not even close to the restriction of modifying the list structure itself, which also means the cdr. But even (cdr x) would be just fine, because it would only modify the conses that were the elements of the list. In particular, after (foo bar), bar would have a contents like ((A ...) (A ...) (A ...) ...). -- Erik Naggum, Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.