User Tools


Differences

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

Link to this comparison view

cl:functions:copy-list [2019/06/15 02:00]
cl:functions:copy-list [2019/08/17 15:00] (current)
Line 1: Line 1:
 +====== Function COPY-LIST ======
 +
 +====Syntax====
 +  * **copy-list** //list// → //copy//
 +
 +====Arguments and Values====
 +  * //list// - a //​[[CL:​Glossary:​proper list]]// or a //​[[CL:​Glossary:​dotted list]]//.
 +  * //copy// - a //​[[CL:​Glossary:​list]]//​.
 +
 +====Description====
 +Returns a //​[[CL:​Glossary:​copy]]//​ of //list//. If //list// is a //​[[CL:​Glossary:​dotted list]]//, the resulting //​[[CL:​Glossary:​list]]//​ will also be a //​[[CL:​Glossary:​dotted list]]//​. ​
 +
 +Only the //​[[CL:​Glossary:​list structure]]//​ of //list// is copied; ​ the //​[[CL:​Glossary:​element|elements]]//​ of the resulting list are  the //​[[CL:​Glossary:​same]]//​ as the corresponding //​[[CL:​Glossary:​element|elements]]//​ of the given //list//.
 +
 +====Examples==== ​   ​
 +<​blockquote>​
 +([[CL:​Macros:​defparameter]] *list* (list 1 (list 2 3))) <​r>​*LIST*</​r>​
 +([[CL:​Macros:​defparameter]] *uncopied-list* *list*) <​r>​*UNCOPIED-LIST*</​r>​
 +([[CL:​Macros:​defparameter]] *copied-list* (copy-list *list*)) <​r>​*COPIED-LIST*</​r>​
 +([[CL:​Functions:​eq]] *uncopied-list* *list*) <​r>//​[[CL:​Glossary:​true]]//</​r>​
 +([[CL:​Functions:​eq]] *copied-list* *list*) <​r>//​[[CL:​Glossary:​false]]//</​r>​
 +([[CL:​Functions:​equal]] *copied-list* *list*) <​r>//​[[CL:​Glossary:​true]]//</​r>​
 +([[CL:​Functions:​rplaca]] *list* "​one"​) <​r>​("​one"​ (2 3))</​r>​
 +*uncopied-list* <​r>​("​one"​ (2 3))</​r>​
 +*copied-list* <r>(1 (2 3))</​r>​
 +([[CL:​Macros:​[[CL:​Macros:​setf]]]] ([[CL:​Functions:​caadr]] *list*) "​two"​) <​r></​r>​
 +*list* <​r>​("​one"​ ("​two"​ 3))</​r>​
 +*uncopied-list* <​r>​("​one"​ ("​two"​ 3))</​r>​
 +*copied-list* <r>(1 ("​two"​ 3))</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +The consequences are undefined if //list// is a //​[[CL:​Glossary:​circular list]]//.
 +
 +====See Also====
 +**[[CL:​Functions:​copy-alist|Function COPY-ALIST]]**,​ **[[CL:​Functions:​copy-seq|Function COPY-SEQ]]**,​ **[[CL:​Functions:​copy-tree|Function COPY-TREE]]**
 +
 +====Example Implementation====
 +To be done.
 +
 +====Notes====
 +The copy created is **[[CL:​Functions:​equal]]** to //list//, but not **[[CL:​Functions:​eq]]**.
 +