Go to the first, previous, next, last section, table of contents.


for

for i from 1 upto   9 by 1 do{ ... }
for i from 9 downto 1 by 1 do{ ... }
for i from 1 below  9 by 1 do{ ... }
for i from 9 above  1 by 1 do{ ... }
file: job.t
package: muf
status: alpha

The for construct is Muq MUF's tool for interating a specified number of times.

The "by" value should always be positive, and defaults to one if not specified.

The "from" value defaults to zero if not specified.

The "upto" value specifies a limit which is to be reached: The index variable may have this value on the final iteration.

The "below" value specifies a limit which is not to be reached: The index variable must be below this value on the final iteration.

The "downto" value specifies a limit which is to be reached: The index variable may have this value on the final iteration.

The "above" value specifies a limit which is not to be reached: The index variable must be above this value on the final iteration.

If "downto" or "above" are supplied, the loop runs towards smaller values, else it runs toward larger values.

Stack:
[ for i below 10 do{ i } |
Stack: [ 0 1 2 3 4 5 6 7 8 9 |
]pop for b from 9 downto 0 do{ [ "%d beers on the shelf!\n" b | ]print , }
9 beers on the shelf!
8 beers on the shelf!
7 beers on the shelf!
6 beers on the shelf!
5 beers on the shelf!
4 beers on the shelf!
3 beers on the shelf!
2 beers on the shelf!
1 beers on the shelf!
0 beers on the shelf!
Stack: 


Go to the first, previous, next, last section, table of contents.