Created
January 10, 2013 04:07
-
-
Save gtrak/4499370 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 let-map | |
"Avoids having to build maps from let bindings manually" | |
[bindings] | |
(let [names (->> (take-nth 2 bindings) | |
(tree-seq #(or (sequential? %) (map? %)) identity) | |
(filter symbol?) | |
(into #{})) ; dumps it all into a set | |
bindings (destructure bindings)] | |
`(let [~@bindings] | |
(zipmap [~@(map keyword names)] | |
[~@names])))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment