Whoa! Thanks Juan. I will start to understand/analyze this...
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of JuanManuel Gimeno Illa
Sent: Tuesday, May 03, 2011 11:40 AM
To: clojure@googlegroups.com
Subject: Re: RE: Multi-level
I'm sure this can be simplyfied:
(defn mlg [attrs data]
(if (empty? attrs)
[ (reduce + (map :mv data)) {:children data}]
(let [parts (group-by (first attrs) data)
subtrees (map (fn [[value data]]
[value (mlg (rest attrs) (map #(dissoc % (first
I'm sure this can be simplyfied:
(defn mlg [attrs data]
(if (empty? attrs)
[ (reduce + (map :mv data)) {:children data}]
(let [parts (group-by (first attrs) data)
subtrees (map (fn [[value data]]
[value (mlg (rest attrs) (map #(dissoc % (first
at
@googlegroups.com
Subject: Re: Multi-level bucketing problem
One way is not to use a tree structure but to aggregate by "composed"
keys, starting with [:attr1] then [:attr1 :attr2] ...
(defn sum-by [data attrs]
(let [aggregated (group-by (apply juxt attrs) data)]
(zipmap (keys aggregated) (ma
Google Collections has a multimap that could help you with this. It
is pretty cool.
As a note they actually push immutability pretty hard - maybe Rich got
to them?
http://guava-libraries.googlecode.com/svn/tags/release09/javadoc/com/google/common/collect/Multimaps.html
On May 1, 10:57 pm, "Bh
One way is not to use a tree structure but to aggregate by "composed" keys,
starting with [:attr1] then [:attr1 :attr2] ...
(defn sum-by [data attrs]
(let [aggregated (group-by (apply juxt attrs) data)]
(zipmap (keys aggregated) (map #(reduce + (map :mv %)) (vals
aggregated)
(println