User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:copy-alist [2019/06/15 02:00]
cl:functions:copy-alist [2019/06/18 09:00] (current)
Line 1: Line 1:
 +====== Function COPY-ALIST ======
 + 
 +====Syntax====
 +  * **copy-alist** //alist// → //​new-alist//​
 +
 +====Arguments and Values====
 +  * //alist// - an //​[[CL:​Glossary:​association list]]//.
 +  * //​new-alist//​ - an //​[[CL:​Glossary:​association list]]//.
 +
 +====Description====
 +Returns a //​[[CL:​Glossary:​copy]]//​ of //alist//.
 +
 +The //​[[CL:​Glossary:​list structure]]//​ of //alist// is copied, and the //​[[CL:​Glossary:​element|elements]]//​ of //alist// which are //​[[CL:​Glossary:​cons|conses]]//​ are also copied (as //​[[CL:​Glossary:​conses]]//​ only). ​ Any other //​[[CL:​Glossary:​object|objects]]//​ which are referred to, whether directly or indirectly, by the //alist// continue to be shared.
 +
 +====Examples====
 +<​blockquote>​
 +(defparameter *alist* (acons 1 "​one"​ (acons 2 "​two"​ '()))) <​r>​*ALIST*</​r>​
 +*alist* <​r>​((1 . "​one"​) (2 . "​two"​))</​r>​
 +(defparameter *list-copy* (copy-list *alist*)) <​r>​*LIST-COPY*</​r>​
 +*list-copy* <​r>​((1 . "​one"​) (2 . "​two"​))</​r>​
 +(defparameter *alist-copy* (copy-alist *alist*)) <​r>​*ALIST-COPY*</​r>​
 +*alist-copy* <​r>​((1 . "​one"​) (2 . "​two"​))</​r>​
 +([[CL:​Macros:​setf]] (cdr (assoc 2 *alist-copy*)) "​deux"​) <​r>"​deux"</​r>​
 +*alist-copy* <​r>​((1 . "​one"​) (2 . "​deux"​))</​r>​
 +*alist* <​r>​((1 . "​one"​) (2 . "​two"​))</​r>​
 +([[CL:​Macros:​setf]] (cdr (assoc 1 *list-copy*)) "​uno"​) <​r>"​uno"</​r>​
 +*list-copy* <​r>​((1 . "​uno"​) (2 . "​two"​))</​r>​
 +*alist* <​r>​((1 . "​uno"​) (2 . "​two"​))</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +**[[CL:​Functions:​copy-list|Function COPY-LIST]]**
 +
 +====Example Implementation====
 +To be done.
 +
 +====Notes====
 +None.
 +