diff src/fns.c @ 401:24b63d6679b6

*** empty log message ***
author Roland McGrath <roland@gnu.org>
date Sun, 18 Aug 1991 01:37:14 +0000
parents 21aa17a1560d
children 4c9349866dac
line wrap: on
line diff
--- a/src/fns.c	Sun Aug 18 01:05:27 1991 +0000
+++ b/src/fns.c	Sun Aug 18 01:37:14 1991 +0000
@@ -644,6 +644,39 @@
   return list;
 }
 
+DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
+  "Delete by side effect any occurrences of ELT as a member of LIST.\n\
+The modified LIST is returned.  Comparison is done with `equal'.\n\
+If the first member of LIST is ELT, there is no way to remove it by side effect;\n\
+therefore, write `(setq foo (delete element foo))'\n\
+to be sure of changing the value of `foo'.")
+  (elt, list)
+     register Lisp_Object elt;
+     Lisp_Object list;
+{
+  register Lisp_Object tail, prev;
+  register Lisp_Object tem;
+
+  tail = list;
+  prev = Qnil;
+  while (!NULL (tail))
+    {
+      tem = Fcar (tail);
+      if (Fequal (elt, tem))
+	{
+	  if (NULL (prev))
+	    list = Fcdr (tail);
+	  else
+	    Fsetcdr (prev, Fcdr (tail));
+	}
+      else
+	prev = tail;
+      tail = Fcdr (tail);
+      QUIT;
+    }
+  return list;
+}
+
 DEFUN ("nreverse", Fnreverse, Snreverse, 1, 1, 0,
   "Reverse LIST by modifying cdr pointers.\n\
 Returns the beginning of the reversed list.")