"Donovan Parks" <······@uvic.ca> writes:
> Hello,
>
> I have a list of list in the following format:
> L = ((0 0 0 0) (0 0 0 0) (0 0 0 0))
>
> Now, I need to be able to change an arbitrary atom. For example, I would
> like to modify the list so that is becomes:
> L' = ((0 X 0 0) (0 0 0 0) (0 0 0 0))
>
> I thought I could do this using setf as follows:
> (setf (nth 2 (nth 1 L) 'X))
>
> Unfortunately, this results in:
> L' = ((0 X 0 0) (0 X 0 0) (0 X 0 0))
Looks like the 3 sublists are the same list.
Why not use an array, anyway?
(defparameter *array* (make-array '(3 4)))
(setf (aref *array* 1 2) 'X)
--
-> -/ - Rahul Jain - \- <-
-> -\ http://linux.rice.edu/~rahul -=- ············@techie.com /- <-
-> -X "Structure is nothing if it is all you got. Skeletons spook X- <-
-> -/ people if [they] try to walk around on their own. I really \- <-
-> -\ wonder why XML does not." -- Erik Naggum, comp.lang.lisp /- <-
|--|--------|--------------|----|-------------|------|---------|-----|-|
(c)1996-2002, All rights reserved. Disclaimer available upon request.