Here's how this structure works when you execute the program:
1. The IF command simply marks the start of the structure.
be anywhere before the THEN command.
2. X is evaluated.
3. The number 0 goes on the stack.
4. The command
takes the value of X and the number 0 as
• If the arguments are "not equal",
• If the arguments are
5. The command THEN takes 1 or 0 as its argument.
• If its argument is 1, THEN evaluates the program up to ELSE
• If its argument is 0, THEN evaluates the program from ELSE
to END (namely 1).
6. Program execution continues after the END command.
Before continuing with specifics about conditional structures, here's
some general information about program structures.
Program-Structure Commands. The commands IF, THEN, ELSE,
and END are examples of
The order and
meaning of these commands are similar to their use in English. You
can't use program-structure commands as flexibly as other commands;
they work only in the combinations described in this chapter.
Test Functions and Commands. The function
is called a
Given two numbers,
returns 1 or 0, indicating whether the
test is true or false. Other test functions are
is used for equations, not to test equality.) Given
symbolic arguments, test functions return a symbolic result.
There are also test commands that always return 1 or O. For example,
the test command SAME is similar to
but it simply tests whether
the two objects are identical. Additional test commands are available
for working with flags (described next). For more information about
test functions and commands, see "PROGRAM TEST' in the Refer-
26: Program Structures