So I have the below hash map of k/v:
(def data [{:ID "0000010890" :CREDIT "EM 1"}
{:ID "0000010890" :CREDIT "FLOW 1"}
{:ID "0000010890" :CREDIT "EM 1"}
{:ID "0000010890" :CREDIT "FLOW 1"}
{:ID "0000010809" :CREDIT "FLOW 1"}])
which I need to merge in to this:
[{:ID "0000010890" :CREDIT "EM 1, FLOW 1"}
{:ID "0000010809" :CREDIT "FLOW 1"}]
Can anyone advise the best way to go about this in clojure?
My attempt:
(defn- create-issue-summary-2 [data]
(->> data
(group-by :ID)
(map (fn [[k v]] (into {:ID k} (apply merge-with (map #(dissoc % :ID) v)))))))
Which results in
({:ID "0000010890", :CREDIT "FLOW 1"}
{:ID "0000010809"})