Created
December 3, 2012 15:57
-
-
Save oskarkv/4195917 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
(defmacro match-def [op name sub? kwargs?] | |
(with-gensyms [sub kwargs re input] | |
(let [args [re input] | |
args (if sub? (conj args sub) args) | |
args (if kwargs? (conj args kwargs) args)] | |
`(~op ~name ~args | |
(let [matches# (map :saved (regex-seq ~re ~input ~(if kwargs? kwargs {})))] | |
(mapv #(get-submatch ~input ~(if sub? sub 0) %) | |
matches#)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment