Skip to content

Instantly share code, notes, and snippets.

@megakorre
Created August 21, 2012 09:23
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 megakorre/3413869 to your computer and use it in GitHub Desktop.
Save megakorre/3413869 to your computer and use it in GitHub Desktop.
let-map
(defmacro let-map [& bindings]
`(let ~(into [] bindings)
~(reduce
(fn [p [n _]]
(if (= \- (first (name n)))
p
(assoc p (keyword (name n)) n)))
{}
(partition 2 bindings))))
(let-map id 23 ;; (compute-id)
-priv "private value"
name (str "users-" id)) ; => { :id 23 :name "users-23" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment