Created
October 30, 2013 03:56
-
-
Save gabriel-laddel/7227016 to your computer and use it in GitHub Desktop.
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
(defn m->ds | |
"Accepts a hashmap, which is then converted into its destructuring syntax." | |
[m] | |
(loop [ks (keys m) | |
acc {}] | |
(if (empty? ks) | |
acc | |
(recur (rest ks) | |
(let [fk (first ks) | |
v (get m fk) | |
sfk (symbol (apply str (rest (str fk))))] | |
(assoc acc (if (map? v) (m->ds v) sfk) fk)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment