liveBook · Manning

Not-any?

As explained in Clojure: The Essential Reference

not-any? is a Clojure function that returns the logical negation of some for a predicate and collection.

not-any? answers whether no element in a collection satisfies a predicate. It is equivalent to negating some on the same predicate and collection, and always returns true or false. section 8.1.5

The function accepts:

  • pred, a one-argument function; any returned value is interpreted using Clojure truthiness. section 8.1.5
  • coll, a collection usable with seq, including standard Clojure collections, arrays, and java.util.Collection types. section 8.1.5
  • A collection that does not support the sequential interface causes IllegalArgumentException; transients are the standard-library exception. section 8.1.5

Checking that no value matches

(not-any? neg? [1 2 0 3]) ;; true No element is negative, so not-any? returns true. The complementary query, (some neg? [1 2 0 3]), would indicate whether at least one element satisfies neg?. section 8.1.5

How Clojure: The Essential Reference covers it

How deep it goes
Defines inputs, truthiness, output, equivalent operations, accepted collections, and an invalid-input exception.
Examples
Uses a neg? check over [1 2 0 3] and lists the related predicate-function family.
What it assumes
Assumes familiarity with one-argument functions, predicates, collections, seq, and Clojure truthiness.
What you can do after
Apply it via Clojure to test whether no collection element satisfies a predicate.
How it connects
Connects not-any? with some, every?, not-every?, predicates, collections, and Boolean logic.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.