# HG changeset patch # User Luc Teirlinck # Date 1074556091 0 # Node ID ee432d9e3bbd8516ac223e5926f37f78ca2f33c5 # Parent 144ae07b9f7328222cbef3d0e4031bbee5fcd8b2 (delete-dups): New function. diff -r 144ae07b9f73 -r ee432d9e3bbd lisp/subr.el --- a/lisp/subr.el Mon Jan 19 15:18:22 2004 +0000 +++ b/lisp/subr.el Mon Jan 19 23:48:11 2004 +0000 @@ -209,6 +209,21 @@ (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil)) x)))) +(defun delete-dups (list) + "Destructively return LIST, with `equal' duplicates removed. +LIST must be a proper list. The value of LIST after a call to +this function is undefined. Use \(setq LIST (delete-dups LIST)) +if you want to store the return value in LIST. Of several +`equal' occurrences of an element in LIST, the last one is kept." + (while (member (car list) (cdr list)) + (pop list)) + (let ((tail list)) + (while tail + (while (member (cadr tail) (cddr tail)) + (setcdr tail (cddr tail))) + (pop tail))) + list) + (defun number-sequence (from &optional to inc) "Return a sequence of numbers from FROM to TO (both inclusive) as a list. INC is the increment used between numbers in the sequence and defaults to 1.