changeset 30515:6165183bc490

(remove, remq): New functions.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 27 Jul 2000 20:08:47 +0000
parents 42bf9adb59a3
children 148c11ee6b89
files lisp/subr.el
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Thu Jul 27 20:07:12 2000 +0000
+++ b/lisp/subr.el	Thu Jul 27 20:08:47 2000 +0000
@@ -135,6 +135,22 @@
       (setq x (cdr x)))
     x))
 
+(defun remove (elt seq)
+  "Return a copy of SEQ with all occurences of ELT removed.
+SEQ must be a list, vector, or string.  The comparison is done with `equal'."
+  (if (nlistp seq)
+      ;; If SEQ isn't a list, there's no need to copy SEQ because
+      ;; `delete' will return a new object.
+      (delete elt seq)
+    (delete elt (copy-sequence seq))))
+
+(defun remq (elt list)
+  "Return a copy of LIST with all occurences of ELT removed.
+The comparison is done with `eq'."
+  (if (memq elt list)
+      (delq elt (copy-sequence list))
+    list))
+
 (defun assoc-default (key alist &optional test default)
   "Find object KEY in a pseudo-alist ALIST.
 ALIST is a list of conses or objects.  Each element (or the element's car,