Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created April 9, 2017 09:23
Show Gist options
  • Save iporsut/c0127aad8a447b93dedc20fc32292b01 to your computer and use it in GitHub Desktop.
Save iporsut/c0127aad8a447b93dedc20fc32292b01 to your computer and use it in GitHub Desktop.
map-flatten
(defn map-flatten
([params]
(into {} (map-flatten params nil)))
([params prefix]
(mapcat (fn [[k v]]
(let [prefix (if (nil? prefix) (name k) (str prefix "[" (name k) "]"))]
(if (map? v)
(map-flatten v prefix)
[{prefix v}])))
params)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment