- DOxxx performs the loop
- Indices are integers.
- forms of DO
one-bound {BODY} DO) \ 0 ... one-bound-1
one-bound {BODY} DO] \ 1 ... one-bound
b1 b2 {BODY} DO[] \ b1 .. b2
b1 b2 stride {BODY} DO[..] \ b1 b1+stride b1+2*stride .. b2
Maybe
b1 b2 {BODY} DO[) \ b1 .. b2-1
to accommodate
array length OVER + {BODY} DO[)
Note the stride is now constant obviously.
If it is negative, the loop goes down.
If you want to straddle from positive to negative (addresses?),
program it explicitly and conspicuously.
Note 1
The [ ) convention comes from mathematics, example:
[1,9] interval 1 2 3 4 5 6 7 8 9
[1,9) interval 1 2 3 4 5 6 7 8
(0,9) interval 1 2 3 4 5 6 7 8
Note 2
{BODY} leans heavily on [: ;] presence. (Or ciforth's { } )
Note 3
If you want to change the stride mid-program, you have to
use BEGIN WHILE REPEAT, as you should have done in the first place.
The four DO's replace the four don't's : ?DO DO LOOP +LOOP .
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 914 |
Nodes: | 10 (1 / 9) |
Uptime: | 232:16:00 |
Calls: | 12,157 |
Files: | 186,518 |
Messages: | 2,232,604 |