Function: -distinct
-distinct is a byte-compiled function defined in dash.el.
Signature
(-distinct LIST)
Documentation
Return a copy of LIST with all duplicate elements removed.
The test for equality is done with equal, or with -compare-fn
if that is non-nil.
Alias: -uniq.
Aliases
Source Code
;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -distinct (list)
"Return a copy of LIST with all duplicate elements removed.
The test for equality is done with `equal', or with `-compare-fn'
if that is non-nil.
Alias: `-uniq'."
(declare (important-return-value t))
(let (test len)
(cond ((null list) ())
;; Use a hash table if `-compare-fn' is a known hash table
;; test function and the list is long enough.
((and (setq test (dash--hash-test-fn))
(> (setq len (length list)) dash--short-list-length))
(let ((ht (make-hash-table :test test :size len)))
(--filter (unless (gethash it ht) (puthash it t ht)) list)))
((let ((member (dash--member-fn)) uniq)
(--each list (unless (funcall member it uniq) (push it uniq)))
(nreverse uniq))))))