Thank you for sharing.
I think the final `s` needs to be `data`, right?
On 16 Jan 2014, at 14:53, Jan Herich wrote:
> Here we go, more generic solution:
>
> (defn transform [data delimiter]
> (reduce (fn [acc [k v]]
> (let [key-strs (-> k (name) (str/split delimiter))]
> (assoc-in
"B"})
>
> (group-by #(-> % first str second str keyword) v)
>
> =>{:b [[:b--name "B"] [:b--id 2]], :a [[:a--id 1] [:a--name "A"]]}
>
> (reduce-kv #(assoc % %2 (into {} %3)) {} *1)
>
> => {:a {:a--id 1, :a--name "A"}, :b {:b-
Hello all,
I've found myself stuck trying to move matching keys in a hash into a
nested hash.
For example,:
{:a--id 1 :a--name "A" :b--id 2 :b--name "B"} ;=> {:a {:id 1 :name "A"} :b
{:id 2 :name "B"}}
I've tried `clojure.walk`, I've tried building the args to `assoc-in`, and
using `apply`.