Hi,
maybe using group-by works?
(defn custom-merge
[maps]
(->> maps
(apply concat)
(group-by :id)
(sort-by key)
(map (comp first val
I'm not sure about the efficiency, though. If you don't need the result sorted
by :id you might replace the sort and the map by “vals (map
On Sun, Dec 25, 2011 at 10:37 AM, Baishampayan Ghose wrote:
> Shoeb wants to merge sequences of maps and not the maps themselves, so
> merge/merge-with won't help him much.
Sorry, I may have misunderstood, I was thinking something like this
(where select-code implements his selecting codes from t
>> Is there a more efficient, cleaner
>> and idiomatic way to do this. Am I missing out on any core library
>> functions that already provide this behavior?
>
> I believe the core function "merge-with" may give you what you are
> looking for:
> http://clojure.github.com/clojure/clojure.core-api.ht
On Sun, Dec 25, 2011 at 10:25 AM, Shoeb Bhinderwala
wrote:
> I want to merge lists of maps. Each map entry > I have written the
> implementation.
> [...]
> Is there a more efficient, cleaner
> and idiomatic way to do this. Am I missing out on any core library
> functions that already provide this
I want to merge lists of maps. Each map entry has an :id and :code
key. The code associated to :id from one map should have higher
precedence than the same :id entry from another map.
I have an implementation. The problem and solution is best described
using example:
;priority 1 map
(def p1 [{:i