191 |
(delq elt (copy-sequence list)) |
(delq elt (copy-sequence list)) |
192 |
list)) |
list)) |
193 |
|
|
|
(defun copy-list (list) |
|
|
"Return a copy of a list, which may be a dotted list. |
|
|
The elements of the list are not copied, just the list structure itself." |
|
|
(if (consp list) |
|
|
(let ((res nil)) |
|
|
(while (consp list) (push (pop list) res)) |
|
|
(prog1 (nreverse res) (setcdr res list))) |
|
|
(car list))) |
|
|
|
|
194 |
(defun copy-tree (tree &optional vecp) |
(defun copy-tree (tree &optional vecp) |
195 |
"Make a copy of TREE. |
"Make a copy of TREE. |
196 |
If TREE is a cons cell, this recursively copies both its car and its cdr. |
If TREE is a cons cell, this recursively copies both its car and its cdr. |
197 |
Contrast to copy-sequence, which copies only along the cdrs. With second |
Contrast to `copy-sequence', which copies only along the cdrs. With second |
198 |
argument VECP, this copies vectors as well as conses." |
argument VECP, this copies vectors as well as conses." |
199 |
(if (consp tree) |
(if (consp tree) |
200 |
(let ((p (setq tree (copy-list tree)))) |
(let (result) |
201 |
(while (consp p) |
(while (consp tree) |
202 |
(if (or (consp (car p)) (and vecp (vectorp (car p)))) |
(let ((newcar (car tree))) |
203 |
(setcar p (copy-tree (car p) vecp))) |
(if (or (consp (car tree)) (and vecp (vectorp (car tree)))) |
204 |
(or (listp (cdr p)) (setcdr p (copy-tree (cdr p) vecp))) |
(setq newcar (copy-tree (car tree) vecp))) |
205 |
(cl-pop p))) |
(push newcar result)) |
206 |
|
(setq tree (cdr tree))) |
207 |
|
(nreconc result tree)) |
208 |
(if (and vecp (vectorp tree)) |
(if (and vecp (vectorp tree)) |
209 |
(let ((i (length (setq tree (copy-sequence tree))))) |
(let ((i (length (setq tree (copy-sequence tree))))) |
210 |
(while (>= (setq i (1- i)) 0) |
(while (>= (setq i (1- i)) 0) |
211 |
(aset tree i (copy-tree (aref tree i) vecp)))))) |
(aset tree i (copy-tree (aref tree i) vecp))) |
212 |
tree) |
tree) |
213 |
|
tree))) |
214 |
|
|
215 |
(defun assoc-default (key alist &optional test default) |
(defun assoc-default (key alist &optional test default) |
216 |
"Find object KEY in a pseudo-alist ALIST. |
"Find object KEY in a pseudo-alist ALIST. |