Skip to content

Instantly share code, notes, and snippets.

@michaelsbradleyjr
Created May 6, 2015 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaelsbradleyjr/c700e265a64c2f2feb91 to your computer and use it in GitHub Desktop.
Save michaelsbradleyjr/c700e265a64c2f2feb91 to your computer and use it in GitHub Desktop.
(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