How to modify elements of a list
Posted: Wed Jul 14, 2010 11:05 am
Hi all, I'm approching Common Lisp but I'm having problems with functions that manipulate lists.
In my program I have something like this:
(defun ac(var val domain)
(let*
(
(x nil)
(dom nil)
)
(setq dom (copy-list domain))
(dolist (x dom)
(if(equal (third x) var)
(progn
(setf (first x) val)
(setf (second x) val)
(return)
)
)
) ; end of dolist
(println dom)
(println domain)
...
...
Println is a function of mine wich displays elements of a list.
The problem is that "dom" and "domain" contain the same elements when I print them, while I want "domain" to store the initial elements.
How can I do that?
Thanks
In my program I have something like this:
(defun ac(var val domain)
(let*
(
(x nil)
(dom nil)
)
(setq dom (copy-list domain))
(dolist (x dom)
(if(equal (third x) var)
(progn
(setf (first x) val)
(setf (second x) val)
(return)
)
)
) ; end of dolist
(println dom)
(println domain)
...
...
Println is a function of mine wich displays elements of a list.
The problem is that "dom" and "domain" contain the same elements when I print them, while I want "domain" to store the initial elements.
How can I do that?
Thanks