Skip to content

Instantly share code, notes, and snippets.

@mikeananev
Created October 22, 2021 04:16
Show Gist options
  • Save mikeananev/90761ac4b154095c8ee96b489457b522 to your computer and use it in GitHub Desktop.
Save mikeananev/90761ac4b154095c8ee96b489457b522 to your computer and use it in GitHub Desktop.
Clojure macro to build map from symbols.
(defmacro ->map
"(->map a b) ;;=> {:a a :b b}"
[& symbols]
(assert (every? symbol? symbols))
`(hash-map
~@(interleave (map keyword symbols) symbols)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment