Last active
August 29, 2015 13:57
-
-
Save AlexBaranosky/9756397 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 | |
"Creates a hash-map which can refer to the symbols of the names of the keys | |
declared above." | |
[& kvs] | |
(assert (even? (count kvs))) | |
(let [ks (take-nth 2 kvs) | |
sym-ks (map (comp symbol name) ks) | |
vs (take-nth 2 (rest kvs))] | |
`(let ~(vec (interleave sym-ks vs)) | |
~(apply hash-map (interleave ks sym-ks))))) | |
(comment | |
(let-map | |
:a 1 | |
:b a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment