User Tools


Function COPY-LIST

Syntax

  • copy-list listcopy

Arguments and Values

Description

Returns a copy of list. If list is a dotted list, the resulting list will also be a dotted list.

Only the list structure of list is copied; the elements of the resulting list are the same as the corresponding elements of the given list.

Examples

(defparameter *list* (list 1 (list 2 3)))

*LIST*

(defparameter *uncopied-list* *list*)

*UNCOPIED-LIST*

(defparameter *copied-list* (copy-list *list*))

*COPIED-LIST*

(eq *uncopied-list* *list*)

true

(eq *copied-list* *list*)

false

(equal *copied-list* *list*)

true

(rplaca *list* "one")

("one" (2 3))

*uncopied-list*

("one" (2 3))

*copied-list*

(1 (2 3))

(setf]] (caadr *list*) "two")

*list*

("one" ("two" 3))

*uncopied-list*

("one" ("two" 3))

*copied-list*

(1 ("two" 3))

Side Effects

None.

Affected By

None.

Exceptional Situations

The consequences are undefined if list is a circular list.

See Also

Example Implementation

To be done.

Notes

The copy created is equal to list, but not eq.