clojure.core/any?¶
Returns true given any argument.
Examples¶
Note by kofrasa¶
The current implementation of any? is incorrect and must be fixed IMO. There was a PR (copied below) submitted in 2014 to add a correct implementation which is consistent with behaviour in other languages.
(def
^{:tag Boolean
:doc "Returns true if (pred x) is logical true for any x in coll,
else false."
:arglists '([pred coll])
:added "1.7"}
any? (comp boolean some))
Note by berczeck¶
any? never returns false. Is this a bug?
Note by KyleErhabor¶
You can think of this function as a non-variadic (constantly true).
Note by wildwestrom¶
any?is a predicate that is intended to always return true, so yes it is the correct behavior.any?was added as a predicate to use with spec in the case where any value is valid. It is not a complement tonot-any?, despite that obvious assumption. There are, in the end, only so many words and despite a lot of care in this regard, there are times when these confusions exist....this is similar to
and(for N args) but that does have limits as a macro, orevery?(for a coll), or the higher-order functionevery-predfor creating a composite pred. Depending on your case, one of those probably makes sense.
See also¶
- clojure.core/constantly (3)
- clojure.core/some? (4)
- clojure.core/some (15)
Content from the matching ClojureDocs page, with authors credited on each contribution.