From: Luc T. <te...@dm...> - 2004-02-15 02:29:29
|
Karl Heuer wrote: In keeping with the earlier suggestion that it's better to keep the first of any duplicated elements rather than the last, I propose the following implementation, which satisfies that requirement and is also simpler. (Note that since the first element of the list is always a "keeper", the modified list is always the same as the return value, and it's no longer strictly necessary for the caller to wrap this in a setq.) (defun delete-dups (list) "Destructively return LIST, with `equal' duplicates removed. 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 (setcdr tail (delete (car tail) (cdr tail))) (setq tail (cdr tail)))) list) Did we make a decision on this? I know that Kim supports the change. I do to, although _maybe_ one could change the docstring to: "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." to make clear that no setq is needed. I believe that Karl is a project member and hence probably has write access and signed papers, so he probably could install his new version himself, with or without the above change in the docstring. Sincerely, Luc. |