Question: condition on applyrule while reading in a list

I have two list in which I need to substitute variables from on elist with variables in other list in an expression.

rootElements := [[a, Integer, c, Integer, -k*a, b], [Integer, c, a, Integer, b, -k*a], [Integer, a, b, -k*a, c, Integer], [Integer, a, Integer, c, -k*a, b]];

list1 := [[a[maximum], 0, c[maximum], 0, (-k*a)[minimum], b[minimum]], [0, c[minimum], a[maximum], 0, b[maximum], (-k*a)[maximum]], [0, a[minimum], b[maximum], (-k*a)[maximum], c[maximum], 0], [0, a[minimum], 0, c[minimum], (-k*a)[minimum], b[minimum]]]


let the term be

term :=a*c/(k*a+b);


Terms := seq(applyrule([seq(rootElements[i][j] = list1[i][j], j = 1 .. nops(list1[i]))], term), i = 1 .. nops(list1));

my outputs  are

a[maximum]*c[maximum]/(k*a[maximum]+b[minimum]),# k*a should be minimum, becuae I substituted a earlier it is failing
a[maximum]*c[minimum]/(k*a[maximum]+b[maximum]),
a[minimum]*c[maximum]/(k*a[minimum]+b[maximum]),# k*a should be maximum, becuae I substituted a earlier it is failing
a[minimum]*c[minimum]/(k*a[minimum]+b[minimum]);

is there a way to substitute larger terms first[like -k*a first] and goes to smaller variable??

 I am using applyrule since algsubs cannot do for more than one substitution.Also, I would be glad if any other alternative is provided.
thank you
 

Please Wait...