Google Answers Logo
View Question
 
Q: Maple ( No Answer,   0 Comments )
Question  
Subject: Maple
Category: Computers > Software
Asked by: ignorant-ga
List Price: $2.00
Posted: 10 Sep 2004 07:53 PDT
Expires: 10 Oct 2004 07:53 PDT
Question ID: 399348
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???
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy