Partial application fixes some arguments of an existing function and returns a new function that waits for the rest. In Clojure, it is useful for turning configuration into reusable computational pieces, especially with sequence functions such as map and filter. section 2.2.8
Use partial application to:
- Create a configured function: (def incrementer (partial + 1)); (incrementer 1 1) returns 3. section 2.2.8
- Preserve the remaining arguments and the original function's arity contract; supplying too many arguments raises an ArityException. section 2.2.8
- Prefer partial over a custom wrapper when emphasizing that an existing function is intentionally receiving arguments later. section 2.2.8
Validate configured data
(map (partial validate #{:id :cache :product}) [valid-req invalid-req]) ;; (true false) Here, partial supplies the whitelist while map supplies each request. section 2.2.8
Listing 2.13. → Higher order functions, currying, deferred invocation
(partial ([f]) ([f arg1]) ([f arg1 arg2]) ([f arg1 arg2 arg3]) ([f arg1 arg2 arg3 & more]))
Inspect partial's supported arities and its role alongside higher-order functions, currying, and deferred invocation. section 2.2.8









