Question: Extracting like exponents separately

I am looking to extract exponents from a sum of products of three variables A, B and C. An example being:

f:=5*A^4*B^3*C^7   +   3*A^2*B^1*C^7  +  31*A^3*B^6*C^11  + ...

I used the following procedure to extract the exponents of each variable:

Exponents:= proc(p, x::name)
    local
    t;
    coeffs(p,x,t);
    map(degree, [t], x)
end proc:

This works great and will extract the powers for each term:

Exponents(f,A):        [4,2,3]

Exponents(f,B):        [3,1,6]

However, when the exponents are the same it does not count them twice. An example of this being with the variable C above where two of them have an exponent = 7 and it only counts it once.

Exponents(f,C):        [7,11]

Is there a simple way to modify the procedure to list the powers regardless of if they appear more than once?

Many thanks in advance.

Please Wait...