Possible Duplicate:
List-operations only when restrictions are fulfilled (Part 1)
I have a set of data like:
list = {{Tim, 45},{Mary,100},{Tim,500},{Bob,499},{Mary,50}};
I'm looking for a simple way to total the values based off of the name so that the output would look like: {{Tim,545},{Mary,150},{Bob,499}}
GatherBy[..., First] //. {h___, {a_, b_}, {a_, c_}, t___} :> {h, {a, b + c}, t}(you might need to flatten appropriately at the end) – rm -rf Dec 11 '12 at 18:55GatherBy:) I typed quickly off the top of my head and didn't run it in mma. Fixed it now – rm -rf Dec 11 '12 at 19:09