liveBook · Manning

All

As explained in Clojure: The Essential Reference

every? is a Clojure function that tests whether a predicate returns truthy for every element of a collection.

every? tests whether a predicate returns truthy for every element of a collection, producing a boolean answer for an all-items question. section 8.1.5

Use it with a one-argument predicate and any collection supported by seq.

  • Treat any non-nil, non-false predicate result as truthy; every? itself returns only true or false. section 8.1.5
  • Expect true for an empty collection, because no element violates the predicate. section 8.1.5
  • Use related functions for complementary questions: not-every?, some, and not-any?. section 8.1.5

Checking cards

(defn bingo? [card] (every? drawn card)) (map bingo? cards) ;; (false false true) Here, every? checks whether each number on a card appears in drawn.

How Clojure: The Essential Reference covers it

How deep it goes
Defines inputs, truthiness, outputs, accepted collections, exceptions, logical relatives, and empty-collection behavior.
Examples
Uses positive numbers, nested sequences, bingo cards, empty collections, and large ranges.
What it assumes
Assumes familiarity with Clojure predicates, collections, truthiness, and basic function application.
What you can do after
Apply every? to validate that all values in a collection satisfy a Clojure predicate.
How it connects
Connects every? with predicates, seq, not-every?, some, and not-any? through Boolean logic.

Also explained in

Compare how 4 books explain all →

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.