## How to program a for loop inside a procedure and m...

I'm trying to program a procedure that will return me a list of positions defining equally spaced points (planets) around a circumference, for example:
PSI := [0, Pi]; # Location of 2 planets
PSI := [0, ((2/3)*Pi) , ((4/3)*Pi) ]; # For 3 Planets
I'm new to maple so most commands are new to me, I tried building the size of the list with [0 \$ n] because I want the first position to always be at 0 degrees. The first problem is that I get this error:

 > nplanets := 2;
 (1)
 > make_PSI := proc(nplanets); local n,psin,i,PSI: n = nplanets; psin  :=(pi*2)/n; PSI := [0 \$ n]; for i from 1 to n do  angle :=(psin*i);  op(i,PSI) := angle; end do; end;
 >
 >

## Why can't I use this while in a procedure?...

I want to use while in proc but Maple shows an error saying

"Error, (in exa) illegal use of a formal parameter"

When I click on it, as usual it says "There is no help page available for this error". I tried a very simple example of while which you can see it below and it again shows same error. The while works well but when I put it inside of a procedure it makes an error. Note: the following example is just an example, this is not what I'm doing so please don't reply this while proc is not giving anything. My question is how can I use a while in procedure without encountering the above error.

i := 10;
while i > 1 do
if i mod 2 = 0 then i := i/2; else i := i+1; end if;
end do;

Now with proc

exa := proc (i::integer)::integer;
while 1 < i do
if i mod 2 = 0 then i :=i/2; else i := i+1; end if
end do;
end proc;

exa(10);

"Error, (in exa) illegal use of a formal parameter"

## User interface ...

Hi, all. I need to built a user interface for my program. First, I create two label and two text area for both the value of x and y. After that I assign a button to random generate the value for x and y within the range with x <y. I write the code below into click action of the button.

use DocumentTools in

Do(%x=RandomTools[Generate](integer(range=1..7);

Do(%y=RandomTools[Generate](integer(range=1..7);

while %x>= %y do

Do(%x=RandomTools[Generate](integer(range=1..7);

Do(%y=RandomTools[Generate](integer(range=1..7);

end do;

end use;

This code can generate two random number and insert inside the boxes created. When the button is clicked, two random number generated but the error dialog box shown on the screen with message : Error in component button with caption "generate" cannot determine if this expression is true or false: %y=%x. What I want is only the true value of x<y will be inserted to the text boxes.

Any suggestion? Any help will be highly appreciated. Thank you.

## procedure that takes integer n and returns an orde...

I need to write a procedure that does the following :

Write a procedure quadsum whose input is an integer n and whose output is a list of pairs of solutions [x,y] to the above formula.

Your procedure should implement the following algorithm.

1 Initialization
Set
"mylist = []."

Start at
x = 0
and
y = 0.

2 Phase A
Increment both
x
and
y
until
"x^2+y^2 >=n."

Phase B
Repeat the following until
x^2>n

If you are above the circle
x^2 + y^2 = n
then go down in unit steps until you are on or below the circle.

If you are on the circle, add the point to the list
"mylist. "

If you are on or below the circle
x^2 + y^2 = n
then go one step to the right. My procedure is as follows: but it runs into an infinite loop(most probably because of the while loop defined inside the while loop). What am I doing incorrectly?

I have atta

## Strange for...while loop behavior?...

Or I didn't get something right? This is with Maple 16.02 on a Mac:

> for i from 1 to 10 while i<=5 do print(i) end do; #works all right
> for i from 1 to 10 while i>=5 do print(i) end do; #nothing shows up?

## Help with loops...

I am trying to work with a for do loop with a while component. I have the error but I am not sure what the desired error should be. I know it has to be small but how small?

Thanks

## How to put the condition in while (z<>ic) to make ...

here is my maple procedure. I have to make the iteration works until I have met the initial condition it will stop. the initial conditions here is z:=ic.

## Simple question about excluding values from for lo...

Say I wanted to print out all values from 1 to 8 but excluding 3, how would I do that using a for loop?

For example, this just stops after 2:

for i to 8 while i <> 3 do
print(i);
end do ;

whereas I want it to skip 3 so going 1,2,4,5,6,7,8.

For what I'm actually doing, I need i to run over a range but excluding one value.

Thanks!

Hi,

statements

## How to display animation in while loop...

I only want to display 'position' in animation while tend <= 12:
This is the trial:

restart:with(plots):
for tend from 0 to 50
while (tend <= 12) do
pos:=animate(textplot3d,[[-1.8,0,alpha*tend, 'position']], tend=0..50,frames=150);
od;
display(pos);

error, (in plots/animate) 0=0..50 is an invalid animation range

Then I try:

restart:with(plots):
while (tend <= 12) do