emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC mode loads CL


From: Luc Teirlinck
Subject: Re: CC mode loads CL
Date: Sun, 18 Jan 2004 22:19:50 -0600 (CST)

There might be a problem with my previous proposal for `delete-dups'.
The function I proposed to copy into subr.el conses up a _new_ list.
That somehow might go against the "spirit" of `delete-dups' (one might
quite as well implement a non-destructive `remove-dups' in that case).
I believe `delete-dups' is supposed to scavenge on the conses of LIST.
The following alternate version does exactly that.  It is not
completely equivalent to the prior version, but instead to:
(delete-duplicates list :test 'equal) with :from-end being nil.  That
is, the last instead of the first of each set of `equal' elements is
kept.  In all instances I am aware of, the order does not matter
anyway.  I could install either version.  I would still double-check
the alternate version more carefully if we decide to go for it.

Alternate version:

(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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]