Contents Previous Next Subchapters

While Statement (Mlmode)
Syntax while expression 
     
statement list 
end
O-Matrix Mode while

Description
The while token begins a block without needing the begin keyword. If any element of the expression following the while is zero, the expression is considered false.

Note that when a while is input at the command line, execution will not occur until the corresponding end is entered.

Example
If in Mlmode you enter
     x = 0;
     while x <= 0 
          x = x + 1;
          x = x + 1;
     end
     x
O-Matrix will reply
     2
Note that the block of statements is executed once, and the block contains two additions.

If you enter
     x = [ 3 2 ];
     while x 
          x = x - 1;
     end
     x
O-Matrix will reply
     [ 1 0 ]