Support list/xs-distinct-by?
Supporting a predicate to check that all elements in a list are distinct after applying a transformation function to them.
This commit is contained in:
parent
3677a7a39e
commit
fa779ab7bf
1 changed files with 5 additions and 0 deletions
|
@ -199,6 +199,11 @@ Be leery of using this with things like alists. Many data structures in Elisp
|
|||
"Return t if X is in XS using `equal'."
|
||||
(-contains? xs x))
|
||||
|
||||
(defun list/xs-distinct-by? (f xs)
|
||||
"Return t if all elements in XS are distinct after applying F to each."
|
||||
(= (length xs)
|
||||
(->> xs (-map f) set/from-list set/count)))
|
||||
|
||||
;; TODO: Support dedupe.
|
||||
;; TODO: Should we call this unique? Or distinct?
|
||||
|
||||
|
|
Loading…
Reference in a new issue