Created
April 9, 2017 09:23
-
-
Save iporsut/c0127aad8a447b93dedc20fc32292b01 to your computer and use it in GitHub Desktop.
map-flatten
This file contains hidden or 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 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