-
-
Save kindlychung/b4b87b9951c05a9cd762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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