In order to simplify my expression, I face a list manipulation problem.
For example, given the input list
list = {a[1] cof[1], a[2] cof[2], a[3] cof[3], a[4] cof[4], a[5] cof[5], a[6] cof[6]};
I can calculate the values of f[a[i]] and then combine the idential elements (f[] is just a function of the a[]). The condition of this transformation is
f[a[1]] == f[a[3]] == f[a[6]]; f[a[2]] == f[a[4]];
so that the output list becomes
newlist = {(cof[1] + cof[3] + cof[6]) a[1], (cof[2] + cof[4]) a[2], cof[5] a[5]};
How can I get this kind transformation to newlist for the general case?

