condp is a Clojure macro for ordered conditional branching: it applies one two-argument predicate to each selector and an expression, returning the first matching choice or default. section 3.3.3
Listing 3.14. Contract
(condp <pred> <expr> [clauses] [<default>]) clause :=> pair || triplet pair :=> <selector> <choice> triplet :=> <selector> :>> <f>
The contract shows the predicate, expression, optional clauses, default, and pair or triplet clause forms. section 3.3.3
Its contract is:
- pred takes selector and expr; its result is interpreted as boolean. section 3.3.3
- Pairs contain selector and choice; triplets contain selector, :>>, and a single-argument function. section 3.3.3
- Clauses run in order, and a missing match without a default throws IllegalArgumentException. section 3.3.3
Matching values and computed conditions
A MIME-type function can match a URL extension with =, while FizzBuzz can test divisibility with #(zero? (mod %2 %1)). For input 15, the first matching selector returns "fizzbuzz". section 3.3.3
Using :>>
With (comp seq filter) as the predicate, :>> passes the predicate result to a function. A card game therefore selects the first matching hand category and applies its ranking function. section 3.3.3
