Created
July 5, 2013 12:24
-
-
Save thheller/5934194 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 cond-transform [x & pairs] | |
(reduce (fn [x [test-fn transform-fn]] | |
(if (test-fn x) | |
(transform-fn x) | |
x)) | |
x | |
pairs)) | |
;; example | |
(cond-transform x | |
[test1 transform1] | |
[test2 transform2] | |
[test3 transform3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment