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:4988 top

(defn distinct?
  "Returns true if no two of the arguments are ="
  {:tag Boolean
   :added "1.0"
   :static true}
  ([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?:
Used in 0 other vars

Comments top

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