Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created March 17, 2012 18:37
Show Gist options
  • Save alandipert/2063919 to your computer and use it in GitHub Desktop.
Save alandipert/2063919 to your computer and use it in GitHub Desktop.
locals map
(defmacro locals
"Returns a map of locals, as keywords, to their values."
[]
(let [locals (keys &env)]
`(zipmap ~@(map vec [(map keyword locals) locals]))))
(let [x 10]
(let [y 20
z (+ x y)]
(locals)))
;=> {:x 10, :y 20, :z 30}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment