while.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary

while.

    while.  T do. B end.
    whilst. T do. B end.
The last sentence executed in the`T` block is tested for a non-zero value in its leading atom. If true, the`B` block is executed. The`T` block is then retested, and so on, continuing until the`T` block tests false. (An empty`T` block result or an omitted`T` block tests true.) `whilst.` differs from`while.` only in that it skips test the first time. `break.``` goes to the end of the`while` or`whilst.` control structure and`` `continue.``` goes to the top.

For example:

    exp =: 4 : 0                  Exponentiation by repeated squaring
     z=.1
     a=.x.
     n=.y.
     while. n do.
      if. 2|n do. z=.z*a end.
      a=.*:a
      n=.<.-:n
     end.
     z
    )

       3 exp 7
    2187

       3 ^ 7
    2187

       1.1 exp 0
    1

       2x exp 128
    340282366920938463463374607431768211456

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary