Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn qc [op & pairs]
(assert (even? (count pairs)))
(fn [coll]
(doseq [[pred msg] (partition 2 pairs)]
(when-not (pred coll)
(throw (IllegalArgumentException. msg))))
(apply op coll)))
(def f1 (qc +
#(= 2 (count %)) "coll must have length 2."
#(even? (first %)) "first elem must be even."
#(odd? (second %)) "second elem must be odd."))
(def f2 (qc -))
(def f3 (qc /))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.