User Guide

8.2 Flow Control
Two basic programming constructs in Maple are the if statement, which
controls the conditional execution of statement sequences, and the for
statement, which controls the repeated execution of a statement sequence.
Conditional Execution (if Statement)
You can specify that Maple perform an action only if a condition holds. You
can also perform an action, from a set of many, depending on which condi-
tions hold.
Using the if statement, you can execute one statement from a series of
statements based on a boolean (true, false, or FAIL) condition. Maple tests
each condition in order. When a condition is satisfied, Maple executes the
corresponding statement, and then exits the if statement.
Syntax
The if statement has the following syntax.
if conditional_expression1 then
statement_sequence1
elif conditional_expression2 then
statement_sequence2
elif conditional_expression3 then
statement_sequence3
...
else
statement_sequenceN
end if;
>
The conditional expressions (conditional_expression1, conditional_expres-
sion2, ...) can be any boolean expression. You can construct boolean expres-
sions using:
Relational operators - <, <=, =, >=, >, <>
322 8 Basic Programming