Skip to content

Instantly share code, notes, and snippets.

@gtrak
Created June 10, 2012 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtrak/2907736 to your computer and use it in GitHub Desktop.
Save gtrak/2907736 to your computer and use it in GitHub Desktop.
(defmacro let-map
"Avoids having to build maps from let bindings manually"
[bindings]
(let [names (->> (tree-seq #(or (vector? %) (map? %)) identity bindings)
(filter symbol?))
bindings (destructure bindings)]
`(let [~@bindings]
(zipmap [~@(map (comp keyword name) names)]
[~@names]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment