Hi Miki
What you provided is an amazing piece of code. I need a lot more time to understand how it works since it uses so many higher order functions. I have uploaded my original problem code base and your solution at: https://gist.github.com/952382 This is just a simplified version of my problem. What we are trying to do is group data in hierarchies and then performs all sorts of calculations on each grouping at each level. The calculations at the lower grouping levels also roll up and feed calculations at the higher levels. Your idea of not creating a tree and simply using functions to compute the values for the groups (nodes) is certainly very thought provoking. Thanks Shoeb ________________________________ From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of Miki Sent: Monday, May 02, 2011 11:33 AM To: clojure@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) (map #(reduce + (map :mv %)) (vals aggregated))))) (println (sum-by data [:attr1 :attr2])) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en