aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2004-02-16 19:40:07 +0000
committerEli Zaretskii2004-02-16 19:40:07 +0000
commit1f3e4f92e703f950db290c62020db7d2158a09ff (patch)
tree6ac7467a55a6df6bd6e0ba8043618fc49e64ebcb
parent279dffd67603744c98614b2cb906a1fc7a5008f6 (diff)
downloademacs-1f3e4f92e703f950db290c62020db7d2158a09ff.tar.gz
emacs-1f3e4f92e703f950db290c62020db7d2158a09ff.zip
(delete-dups): A better implementation from Karl Heuer <kwzh@gnu.org>.
-rw-r--r--lisp/subr.el16
1 files changed, 6 insertions, 10 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 641d81a6fb6..0b3c3df4e8d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -210,18 +210,14 @@ If N is bigger than the length of X, return X."
210 x)))) 210 x))))
211 211
212(defun delete-dups (list) 212(defun delete-dups (list)
213 "Destructively return LIST, with `equal' duplicates removed. 213 "Destructively remove `equal' duplicates from LIST.
214LIST must be a proper list. The value of LIST after a call to 214Store the result in LIST and return it. LIST must be a proper list.
215this function is undefined. Use \(setq LIST (delete-dups LIST)) 215Of several `equal' occurrences of an element in LIST, the first
216if you want to store the return value in LIST. Of several 216one is kept."
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)) 217 (let ((tail list))
221 (while tail 218 (while tail
222 (while (member (cadr tail) (cddr tail)) 219 (setcdr tail (delete (car tail) (cdr tail)))
223 (setcdr tail (cddr tail))) 220 (setq tail (cdr tail))))
224 (pop tail)))
225 list) 221 list)
226 222
227(defun number-sequence (from &optional to inc) 223(defun number-sequence (from &optional to inc)