You're viewing version 1.2.0 of distinct?. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

distinct?

clojure.core

  • (distinct? x)
  • (distinct? x y)
  • (distinct? x y & more)
Returns true if no two of the arguments are =

1 Example top

  • user=> (distinct? 1 2 3)
    true
    user=> (distinct? 1 2 3 3)
    false
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:4521 top

(defn distinct?
  "Returns true if no two of the arguments are ="
  {:tag Boolean
   :added "1.0"}
  ([x] true)
  ([x y] (not (= x y)))
  ([x y & more]
   (if (not= x y)
     (loop [s #{x y} [x & etc :as xs] more]
       (if xs
         (if (contains? s x)
           false
           (recur (conj s x) etc))
         true))
     false)))
Vars in clojure.core/distinct?: = conj contains? defn loop not not=
Used in 0 other vars

Comments top

No comments for distinct?. Log in to add a comment.