Suppose that you want to completely evaluate
where A con-
and P contains 2. The first evaluation of the loop clause
These expressions are not the same, so
the loop clause is evaluated a second time, returning
P +0 +B
2 +G! +B
These expressions are not the same, so the loop clause is
evaluated a third time, returning
2 +0 +B
2 +G! +B
pressions are the same, so the loop structure ends.
The effect of this example is similar to the effect of .... NUM, except
... NUM causes an error if a name is undefined. For a more versatile
version of this example, see "MULTI (Multiple Execution)" on page
WHILE ... REPEAT ... END
The following example takes any number of vectors from the stack
and adds them to the current statistics matrix. Since
needs to test
whether the object in level 1 is a vector
attempting to add it,
this example uses WHILE ... REPEAT ... END.
WHILE DUP TYPE 3
REPEAT I+ END
This structure works as follows:
1. The test clause
is evaluated, leaving a flag on
the stack. The flag indicates whether the object in level 2 is a
The flag is taken from the stack. Its value determines whether
the loop clause is executed .
• If the flag is true, the loop clause
is executed, adding the
vector to the current statistics matrix, and steps (1) and (2) are
• If the flag is false, the loop structure ends.
Note that WHILE ... REPEAT ... END ends when the flag is false,
but DO ... UNTIL ... END ends when the flag is true. If you need to
change the truth value of a test clause, add NOT as the last com-
mand: WHILE ... NOT REPEAT or UNTIL ... NOT END.
For another example of WHILE ... REPEAT ... END, see "PAD (Pad
With Leading Spaces)" on page 257.
26: Program Structures