Skip to content

Instantly share code, notes, and snippets.

@syou6162
Created August 16, 2012 09:58
Show Gist options
  • Save syou6162/3369015 to your computer and use it in GitHub Desktop.
Save syou6162/3369015 to your computer and use it in GitHub Desktop.
;; {:x x, :y y}みたいなhash-mapを毎回作るのがダルくなってきたので...
(defmacro hash-map-by-names [& names]
`(let [pairs# (map (fn [name#]
(list (keyword name#) (deref (resolve name#))))
'~names)]
(apply hash-map (flatten pairs#))))
(def x 1)
(def y 2)
(hash-map-by-names x y) ; {:y 2, :x 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment