Created
August 21, 2012 09:23
-
-
Save megakorre/3413869 to your computer and use it in GitHub Desktop.
let-map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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