The loop begins counting at count and decreases by 1 with each iteration. The loop terminates when the loop index (accessible via I ) is equal to 0. The word LEAVE may be used to conditionally exit the loop early.
Note that a FOR loop counts from count to 0, whereas a DO loop counts from count-1 to 0.
Using a FOR/NEXT loop:
: TEST 10 FOR I . NEXT ;
TEST
10 9 8 7 6 5 4 3 2 1 0 (11 values displayed)
Using a DO/LOOP :
: TEST 10 0 DO I . LOOP ;
TEST
0 1 2 3 4 5 6 7 8 9 (10 values displayed)
|