some-fn combines one or more one-argument predicates into a function that applies them to supplied values and returns the first truthy result. Evaluation short-circuits when a predicate succeeds, while nil or false results continue the search. section 2.2.9
Use some-fn when several alternative tests should be treated as one predicate:
- Pass predicate functions as arguments; the returned function accepts zero or more values. section 2.2.9
- Expect any return type: Clojure truthiness determines whether evaluation stops, but the successful value itself is returned. section 2.2.9
- Avoid predicates requiring more than one argument, and expect ArityException when some-fn receives no predicates. section 2.2.9
Combining email checks
Define spam? with (some-fn any-unwanted-word? any-link? any-blacklisted-sender?). Applying it to tokenized email returns nil for clean input and "click" for a matching message, allowing when-let to raise a diagnostic exception.
