Is the following a bug???
$ maple
|\^/| Maple 9.5 (IBM INTEL LINUX)
._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2004
\ MAPLE / All rights reserved. Maple is a trademark of
<____ ____> Waterloo Maple Inc.
| Type ? for help.
> shift_3 := proc(i) (i-modp(i,3))/3; end;
shift_3 := proc(i) 1/3*i -
1/3*modp(i, 3) end proc
> print_pop := proc(p) local u,s,i; u:= p; s:= array(1..8);
> for i from 1 to 8 do
> s[i]:= modp(u,3);
> u:= shift_3(u);
> od;
> s; end;
print_pop :=
proc(p) local u, s, i; u := p; s := array(1 .. 8); for i to 8 do
s[i] := modp(u, 3); u := shift_3(u) end do; s end proc
> sub_p:= proc(x) local i,s,p; s:= {}; p:= print_pop(x);
> for i from 1 to 8 do
> s:= s union {cat(`x`,i) = p[i]};
> od;
> s; end;
sub_p := proc(x) local i, s, p; s := {}; p := print_pop(x); for i to 8
do s := s union {cat(x, i) = p[i]} end do; s end proc
> print(sub_p(6));
{61 = 0, 62 = 2, 63 = 0, 64 = 0, 65 = 0,
66 = 0, 67 = 0, 68 = 0}
> s:= {}; p:= print_pop(6);
s := {}
p := s
> for i from 1 to 8 do
> s:= s union {cat(`x`,i) = p[i]};
> od;
s := {x1 = 0}
s := {x1 = 0, x2 = 2}
s := {x1 = 0, x2 = 2, x3 = 0}
s := {x1 = 0, x2 = 2, x3 = 0, x4 = 0}
s := {x1 = 0, x2 = 2, x3 = 0,
x4 = 0, x5 = 0}
s := {x1 = 0, x2 = 2, x3 = 0, x4 =
0, x5 = 0, x6 = 0}
s := {x1 = 0, x2 = 2, x3 = 0, x4 = 0,
x5 = 0, x6 = 0, x7 = 0}
s := {x1 = 0, x2 = 2, x3 = 0, x4 = 0, x5 =
0, x6 = 0, x7 = 0, x8 = 0}
> print(s);
{x1 = 0, x2 = 2, x3 = 0, x4 = 0, x5 = 0,
x6 = 0, x7 = 0, x8 = 0}
>quit;
bytes used=214580, alloc=262096, time=0.01
My point is that if I manually type in what sub_p(6) is intended to do,
then I get the expected answer, {x1 = 0, x2 = 2, x3 = 0, x4 = 0, x5 =
0, x6 = 0, x7 = 0, x8 = 0}
However, when I try to invoke the proceedure sub_p(6), what I get is
{61 = 0, 62 = 2, 63 = 0, 64 = 0, 65 = 0, 66 = 0, 67 = 0, 68 = 0}
which is not at all what I intend.
What is going on??? |