Shortand clojure syntax for properties on hashmaps

Continuing the discussion from Shortand clojure syntax for properties on hashmaps:

hmm, as we are using a Lisp, you could use a macro like for example:

(defmacro nmap [& xs] 
    (cons 'hash-map 
              (interleave (map (comp keyword name) xs) xs)))

and then use it like

(let [a 1, b 2, c 3] 
  (nmap a b c))

yielding

{:c 3, :b 2, :a 1}
8 Likes