(= s (distinct s)) looks to me like it should return true if it lacks
duplicates, false if it has duplicates, and, due to how laziness and =
work, short circuit as soon as any duplicate item is found.
Your way sounds closer to how this version works:
(defn dupes? [c]
(->> c
(frequencies)
(vals)
(apply max)
(< 1)))
which works (truthy when there are duplicates this time) but is less
efficient. A low level method would be
(loop [s (seq s) seen? #{}]
(if s
(let [f (first s)]
(when-not (seen? f)
(recur (next s) (conj seen? f))))
true))
That one also returns true on duplicates, and returns nil if there are
none, and short circuits as soon as it sees a duplicate.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.