/[emacs]/emacs/lisp/subr.el
ViewVC logotype

Diff of /emacs/lisp/subr.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.306 by walters, Sat Jun 8 20:48:15 2002 UTC revision 1.307 by rms, Mon Jun 10 09:01:08 2002 UTC
# Line 191  The comparison is done with `eq'." Line 191  The comparison is done with `eq'."
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.

Legend:
Removed from v.1.306  
changed lines
  Added in v.1.307

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26