Hi!
Suppose, we want to expand each A(q?) as B(q)+C(q) if there is tag(q).
Here is the code with $ variables.
c A,B,C,tag,tag2;
v q1,q2,q3,k;
g ff =
+ A(q1)*A(q2)*A(q3) * tag(q2)*tag(q3);
#do i=1,2
* repeat;
if ( match( tag(k?$k) ) );
id tag($k) = tag2($k);
id,many, A($k) = B($k) + C($k);
endif;
* endrepeat;
*.sort
#enddo
id tag2(?a) = tag(?a);
moduleoption local $k;
.sort
b tag,tag2,A;
print+s ff;
.end
This gives
+ A(q1)*tag(q2)*tag(q3) * (
+ B(q2)*B(q3)
+ B(q2)*C(q3)
+ B(q3)*C(q3)
+ C(q3)^2
);
which I find wrong.
But if I uncomment .sort then it works:
+ A(q1)*tag(q2)*tag(q3) * (
+ B(q2)*B(q3)
+ B(q2)*C(q3)
+ B(q3)*C(q2)
+ C(q2)*C(q3)
);
With repeat, instead of #do-cycle, the same story.
In this particular case we can work without $-variable
id tag(q?)*A(q?) = tag(q)*(B(q) + C(q));
But in real code, I need some further manipulations with q.
Hi!
Suppose, we want to expand each A(q?) as B(q)+C(q) if there is tag(q).
Here is the code with $ variables.
This gives
which I find wrong.
But if I uncomment .sort then it works:
With repeat, instead of #do-cycle, the same story.
In this particular case we can work without $-variable
But in real code, I need some further manipulations with q.