aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLuc Teirlinck2004-01-19 23:48:11 +0000
committerLuc Teirlinck2004-01-19 23:48:11 +0000
commit016827560a1b2c3a6de5ebd7e78986d0e72b6a2b (patch)
tree3778d80d1ccfdde31b0056239035849ab74fc11c /lisp
parent412be09bf752821d741c0c304cbe71593f04ecbf (diff)
downloademacs-016827560a1b2c3a6de5ebd7e78986d0e72b6a2b.tar.gz
emacs-016827560a1b2c3a6de5ebd7e78986d0e72b6a2b.zip
(delete-dups): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index c721969ec38..2e7b2f12ab0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -209,6 +209,21 @@ If N is bigger than the length of X, return X."
209 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil)) 209 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
210 x)))) 210 x))))
211 211
212(defun delete-dups (list)
213 "Destructively return LIST, with `equal' duplicates removed.
214LIST must be a proper list. The value of LIST after a call to
215this function is undefined. Use \(setq LIST (delete-dups LIST))
216if you want to store the return value in LIST. Of several
217`equal' occurrences of an element in LIST, the last one is kept."
218 (while (member (car list) (cdr list))
219 (pop list))
220 (let ((tail list))
221 (while tail
222 (while (member (cadr tail) (cddr tail))
223 (setcdr tail (cddr tail)))
224 (pop tail)))
225 list)
226
212(defun number-sequence (from &optional to inc) 227(defun number-sequence (from &optional to inc)
213 "Return a sequence of numbers from FROM to TO (both inclusive) as a list. 228 "Return a sequence of numbers from FROM to TO (both inclusive) as a list.
214INC is the increment used between numbers in the sequence and defaults to 1. 229INC is the increment used between numbers in the sequence and defaults to 1.