Skip to content

Instantly share code, notes, and snippets.

@gabriel-laddel
Created October 30, 2013 03:56
Show Gist options
  • Save gabriel-laddel/7227016 to your computer and use it in GitHub Desktop.
Save gabriel-laddel/7227016 to your computer and use it in GitHub Desktop.
(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