Question: Possible bug in seq(), add(), mul()

There seems to be an "issue" when using a indexed name (say x[4]) as the loop index in a seq() mul() or add() command - the indexed name is assigned once the command exits!!

This never(?) happens if the loop index is not an indexed name. A bug??

See the attached which illustrates the issue for the add() command, where x[4] is assigned on exit from add(). The same thing happens if add() is replaced with seq() or mul()

  restart;

#
# x[4] should not be assigned on exit from add() !!
#
  add( u(x[4]), x[4]=1..10);
  x[4];
#
# x__4 is not assigned on exit from add()
#
  add( u(x__4), x__4=1..10);
  x__4;
#
# j is not assigned on exit from add()
#
  add( u(j), j=1..10);
  j;

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

10

 

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

x__4

 

u(1)+u(2)+u(3)+u(4)+u(5)+u(6)+u(7)+u(8)+u(9)+u(10)

 

j

(1)

 


 

Download aBug.mw

 

 

Please Wait...