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

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

bug#50928: [External] : bug#50928: remove-dups


From: Drew Adams
Subject: bug#50928: [External] : bug#50928: remove-dups
Date: Fri, 1 Oct 2021 17:02:08 +0000

FWIW, I use this.  I don't recall whether I borrowed
it from somewhere or just wrote it from scratch.

(defun my-remove-dups (sequence &optional test)
  "Copy of SEQUENCE with duplicate elements removed.
Optional arg TEST is the test function.  If nil, test with `equal'.
See `make-hash-table' for possible values of TEST."
  (setq test  (or test  #'equal))
  (let ((htable  (make-hash-table :test test)))
    (loop 
     for elt in sequence
     unless (gethash elt htable)
     do     (puthash elt elt htable)
     finally return (loop for i being the hash-values in htable collect i))))

reply via email to

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