# HG changeset patch # User Eli Zaretskii # Date 1076960407 0 # Node ID 15b3e94eebd433d20033bf49845579cdee5a2e7e # Parent beb6050d01470025f458dbf6c447f8b79b9c2f0c (delete-dups): A better implementation from Karl Heuer . diff -r beb6050d0147 -r 15b3e94eebd4 lisp/subr.el --- a/lisp/subr.el Mon Feb 16 19:35:20 2004 +0000 +++ b/lisp/subr.el Mon Feb 16 19:40:07 2004 +0000 @@ -210,18 +210,14 @@ 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)) + "Destructively remove `equal' duplicates from LIST. +Store the result in LIST and return it. LIST must be a proper list. +Of several `equal' occurrences of an element in LIST, the first +one is kept." (let ((tail list)) (while tail - (while (member (cadr tail) (cddr tail)) - (setcdr tail (cddr tail))) - (pop tail))) + (setcdr tail (delete (car tail) (cdr tail))) + (setq tail (cdr tail)))) list) (defun number-sequence (from &optional to inc)