12-23-2016, 02:42 PM
Hello,
Running a TEST program that had previously done no longer works, something was changed?
The logic of the step for FOR falling is contrary to other languages, Why?
for n from 3 to 1 step 1 do // hp-p_pl
for n from 3 to 1 step -1 do // other languages
for (i=3;i>=1;i--) //c++
For this case, I think it is correct and logic
for n from 3 downto 1 do
for n from 3 downto 1 step 1 do
Running a TEST program that had previously done no longer works, something was changed?
The logic of the step for FOR falling is contrary to other languages, Why?
for n from 3 to 1 step 1 do // hp-p_pl
for n from 3 to 1 step -1 do // other languages
for (i=3;i>=1;i--) //c++
For this case, I think it is correct and logic
for n from 3 downto 1 do
for n from 3 downto 1 step 1 do
PHP Code:
export FORtest()
begin
local TYPE_REAL:=0.0, TYPE_INTEGER:=0, TYPE_BOOLEAN:=false, TYPE_STRING:="", TYPE_LIST:={};
local a:=TYPE_LIST;
local c:=TYPE_INTEGER;
local n,m; //i,j
print(); print(""); wait();
a:= makeMat( 0, 1, 10 ); // array 1x10
print( "stores each element of array a");
for c from 1 to 10 do
a(1,c) := c*10;
end;
print( "prints each element of array a");
for c from 1 to 10 do
print ( string( a(1,c)) );
end;
// [[1 2 3 4 5 6 7 8 9 10 ]]
local b:= makeMat( 0, 3, 6 ); // array 3x6 = 18 elements
print( "stores each element of array b");
c:=0;
for n from 1 to 3 do
for m from 1 to 6 do
c:=c+1;
b(n,m):=c;
end;
end;
print( "prints each element of array b");
print( "");
for n from 1 to 3 do
for m from 1 to 6 do
print( string( b (n,m) ) );
end;
end;
// [[1 2 3 4 5 6]
// [7 8 9 10 11 12]
// [13 14 15 16 17 18]]
print( "prints only rows 1,3,5 and cols 3,2,1");
for n from 3 to 1 step -1 do //?
//for n from 3 to 1 step 1 do ?
//for n from 3 downto 1 do // ok
//for n from 3 downto 1 step 1 do // ok
//print ("f:"+n);
for m from 1 to 5 step 2 do
//print ("c:"+m);
print ( string( b(n,m) ) );
end;
end;
// output 13, 15 17 7 9 11 1 3 5
print("Done"); wait();
end;