Items tagged with while while Tagged Items Feed

Hi,

I'm currently writing a programme for synchronising automatas, its creates an array and adds words or matrices to the array that aren't already in. I am currently getting an error when i try and run my procedure though and i'm unsure of the problem, any help would be appreciated, here is my code so far.

Thanks!

proc_cerny1:=proc(A::Matrix,B::Matrix,C::Vector[row],N)
local x, S, i, j, T, R, y, found;
x:=2^N;
S:=Array(0..(x-1));
S[0]:=C;
i:=0;
j:=1;
found:=false;

while (i<(x-1) and i<>j) do
T:=S[i].A;
for y from 0 to j do
if LinearAlgebra:-Equal(S[y],T) then
found:=true;
if (found=false) then
S[j]:=T;
j:=j+1;
end if:
end if:
od:

R:=S[i].B;
for y from 0 to j do
if LinearAlgebra:-Equal(S[y],T) then
found:=true;
if (found=false) then
S[j]:=R;
j:=j+1;
i:=i+1;

end if:
end if:
od:
od:
print(S);
end proc:

 

The error i'm getting is when i input this:

proc_cerny1(Matrix([[1,0,0],[1,0,0],[1,0,0]]),Matrix([[0,1,0],[0,0,1],[0,0,1]]),Vector(1..3,1,orientation=row),3);

and the error is:

Error, (in LinearAlgebra:-Equal) invalid input: LinearAlgebra:-Equal expects its 1st argument, X, to be of type {Matrix, Vector} but received 0

 

Hi all,
I've got this code but the second if statement does not seem to work within the for cycle... If I write it outside the cycle it works... Can you help me with this??? 
 
Dec := {1, 4}; Var := {2, 3, 5, 6}; n[1] := 4; n[2] := 3; n[3] := 2; n[4] := 3; n[5] := 4; n[6] := 2; Ut := {1, 2, 3}; pa[2] := {1}; pa[3] := {1, 2}; pau[1] := {3}; pa[5] := {4}; pau[2] := {5}; pa[6] := {4, 5}; pau[3] := {4, 6}; J := {3, 5, 6};
m := numelems(Ut); n := numelems(`union`(Dec, Var)); j := numelems(J);

if member(n, J) then A[n] := {`union`(pa[n], `intersect`(pau[3], {n}))}; jcur := j-1 end if

for i from n-1 to 1 do if member(i, J) then A[i] := `union`(`union`(A[i+1], pa[i]), `intersect`(pau[jcur], {i})); jcur := j-1 else A[i] := `union`(A[i+1], `intersect`(pa[i], {i})) end if end do

Thanks in advance
manuele

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

maple worksheet snapshot

 

> 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...

November 20 2013 jem4303 5

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

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.


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

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);


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

 

Then I try:

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

Hi I've been searching for an example of a while loop (no recursion) with 2 parts to it, but I have not been able to find one.  Does anyone know of any or can make one up for me?  Thanks!!!

Page 1 of 1