Returns true if (pred x) is logical true for every x in coll, else
false.
;; you can use every? with a set as the predicate to return true if
;; every member of a collection is in the set
user=> (every? #{1 2} [1 2 3])
false
user=> (every? #{1 2} [1 2])
true
;; or use a hash-map as the predicate with every? to returns true
;; if every member of a collection is a key within the map
user=> (every? {1 "one" 2 "two"} [1 2])
true
user=> (every? {1 "one" 2 "two"} [1 2 3])
false
(defn every?
"Returns true if (pred x) is logical true for every x in coll, else
false."
{:tag Boolean
:added "1.0"
:static true}
[pred coll]
(cond
(nil? (seq coll)) true
(pred (first coll)) (recur pred (next coll))
:else false))
Comments top
No comments for every?. Log in to add a comment.