From: David Stevenson
Subject: Re: Please help with copy-list.
Date: 
Message-ID: <3jiki8$ode@rockall.cc.strath.ac.uk>
In article ······@namaste.cc.columbia.edu, David J Topper <····@columbia.edu> () writes:
> I have functions to move "the blank" NORTH,SOUTH, EAST and WEST.  These 
> functions use "fill" to replace items in the given list.  But no 
> matter how I try, I can't get it to work on a COPY of the given list.
>
> ... etc ...

hi,
I don't know how your move-south works, for example, but I suspect it's
manipulating the *elements* of the *inner* lists, and that's why both are getting
changed, because copy-list only alters the `top level' of the list ... it's a
new *list*, but the elements of the new list are still pointing to the *original*
elements ... bottom line is,
                              use copy-tree instead!:

> (setf list1 '((a b c) (d e f) (g h i)))
((A B C) (D E F) (G H I))
> (setf list2 (copy-list list1))
((A B C) (D E F) (G H I))
> (setf list3 (copy-tree list1))
((A B C) (D E F) (G H I))
> (setf (car (car list1)) 'XXX)
XXX
> list1
((XXX B C) (D E F) (G H I))
> list2
((XXX B C) (D E F) (G H I))
> list3
((A B C) (D E F) (G H I))
> 

hope this helps

cheers,
david