Spec - Predicate functionsλ︎
A predicate is a function that returns a true or false value and their names end with ?
by convention.
clojure.core
predicate functions
Predicate functions in specsλ︎
Predicate functions can be used as un-named specifications to test values conform.
Include the clojure.spec.alpha
namespace to access the spec functions.
Custom predicate functionsλ︎
Define custom predicate functions with defn
or fn
or the short form #()
Using an anonymous function
When the expression is quite terse, then the short form of an anonymous function is typically used. The %
represents the value passed as an argument.