The best i could think was:

 (defn calc-types [coll]
  (let [types (map (fn [m] {:type (get m "Type") :value (Double/parseDouble 
(get m "Value"))}) coll)  ; convert keys to keywords and values to doubles
        it1 (sort-by :type types) ; sort by type
        a (atom (:type (first it1)))
        it2 (partition-by (fn [m] (if (not= (:type m) @a) (do (reset! a 
(:type m)) true) false)) it1)] ; partition by type
    (map (fn [l] {:type (:type (first l)), :value (reduce + (map :value 
l))}) it2))) ; map reduce

Hope it helps.
P.S: Try to use keywords and numbers instead of strings, the function will 
be simpler

-- 
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

Reply via email to