Skip to content

Instantly share code, notes, and snippets.

@michaelsbradleyjr
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelsbradleyjr/6f7dc255b6b9cef60384 to your computer and use it in GitHub Desktop.
Save michaelsbradleyjr/6f7dc255b6b9cef60384 to your computer and use it in GitHub Desktop.
(defn qc
[op]
(fn [coll]
(if (not= (count coll) 2)
(throw (IllegalArgumentException. "coll must have length 2.")))
(if (odd? (first coll))
(throw (IllegalArgumentException. "first elem must be even.")))
(if (even? (second coll))
(throw (IllegalArgumentException. "second elem must be odd.")))
(apply op coll)))
(def f1 (qc +))
(def f2 (qc -))
(def f3 (qc /))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment