HyperMath

repeat

repeat

Previous topic Next topic No expanding text in this topic  

repeat

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

The conditional looping statement repeat has the form:

repeat

     block

until exp

Note that exp comes after block in contrast to the while loop format.  For example:

      > i = 3

The following has to be on a single line if typed in the command window; here it’s separated for clarity:

      repeat

      print(i,"\n")

      i = i-1

      until i==0

      3

      2

      1

Like the while statement we can exit a repeat loop using a break statement:

      > i = 1

The following has to be on a single line if typed in the command window; here it’s separated for clarity:

      > repeat

print(i,"\n")

i = i+1

if i>3 then break end

until (i == 10)

1

2

3