Copying a list of common lisp structures

I have a list of structures and I want to write a function that modifies some slots in structures without affecting the original list. I tried using the copy list, but its not deep enough; slot values ​​also change in the source list. My question is, is there a built-in function that does what I want ?, or should I write my own ?. Thanks.

EDIT:

I continued and wrote my own function, is there a built-in that will do this?

(defun deep-copy (li) (if (null li) nil (cons (copy-structure (car li)) (deep-copy (rest li))))) 
+4
source share
1 answer

Not enough value for predefined function.

Your code is simple:

 (mapcar #'copy-structure some-list) 
+10
source

Source: https://habr.com/ru/post/1440197/


All Articles