Consider we have:
list = {{2, 3}, {3, 30}, {3, 2}, {4, 53}}
and we want to compare the first elements and sum the second elements if first elements are similar them we should get a array
newlist = {{2, 3}, {3, 32}, {4, 53}}
So I did the instruction bellow that did not workout.
Table[if[list[[i, 1]] == list[[i + 1, 1]],
{list[[i, 1]], list[[i, 2]] + list[[i + 1, 2]]},
{list[[i, 1]], list[[i, 2]]}], {i, Length[list] - 1}]
How to work around?
If
instead ofif
. Also take a look at patterns -- should be able to cope with difficulty. $\endgroup$