Question: Does printf have an issue with rand?

If I execute a program like:

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives6.txt";
stream := cat(pathname, "\\", filename);
Y := seq(rand(1..10)(), j = 1..10);
writeto(stream);
for i from 1 to 10 do
 printf("X[ %d ]:= %d;\n", i, Y[i]);
end do;
writeto(terminal);
printf("DONE\n");

 

Maple will print exactly what I told it to print.  But when I enter

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives44.txt";
stream := cat(pathname, "\\", filename);
writeto(stream);
for i from 1 to 10 do
 Y := rand(1..10)();
 printf("X[ %d ]:= %d;\n", i, Y);
end do;
writeto(terminal);
printf("DONE\n");

 

Maple prints:

             YAssign7, [Typesetting:-mprintslash([Y := 7], [7])]

X[ 1 ]:= 7;
           YAssign10, [Typesetting:-mprintslash([Y := 10], [10])]

X[ 2 ]:= 10;
             YAssign6, [Typesetting:-mprintslash([Y := 6], [6])]

X[ 3 ]:= 6;
             YAssign2, [Typesetting:-mprintslash([Y := 2], [2])]

X[ 4 ]:= 2;
             YAssign4, [Typesetting:-mprintslash([Y := 4], [4])]

X[ 5 ]:= 4;
             YAssign6, [Typesetting:-mprintslash([Y := 6], [6])]

X[ 6 ]:= 6;
             YAssign5, [Typesetting:-mprintslash([Y := 5], [5])]

X[ 7 ]:= 5;
             YAssign1, [Typesetting:-mprintslash([Y := 1], [1])]

X[ 8 ]:= 1;
             YAssign8, [Typesetting:-mprintslash([Y := 8], [8])]

X[ 9 ]:= 8;
             YAssign5, [Typesetting:-mprintslash([Y := 5], [5])]

X[ 10 ]:= 5;
 

This must be more than a matter of calling rand when I am writing to terminal, for if I enter:

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives8.txt";
stream := cat(pathname, "\\", filename);
writeto(stream);
X := rand(0..1)():
printf("Mary had a little lamb\n");
writeto(terminal);
printf("DONE\n");

 

then all Maple prints is "Mary is a little lamb".  I have tried this on Maple 2018 and Maple 2019, with the same results.

 

Any ideas or suggestions?

Please Wait...