#include "MusimatTutorial.h"Go to the source code of this file.
Functions | |
| MusimatTutorialSection (B0117) | |
| MusimatTutorialSection | ( | B0117 | ) |
Definition at line 2 of file B0117.cpp.
{
Print("*** B.1.17 Compound Statements ***");
/*****************************************************************************
B.1.17 Compound Statements
Suppose we need to do more than one thing depending on the value of a predicate. If we need to execute
multiple statements that depend upon a common predicate, we can group them together into a list of
statements. For example, {m = n; n = r;} is a list of statements, also called a compound state-
ment. Consider steps 2 and 3 of Euclid's method (see section 9.2.2), which can be expressed:
*****************************************************************************/
Integer m, n = 1, r = 1;
If (r == 0)
Halt(n);
Else {
m = n;
n = r;
}
/*****************************************************************************
If r is not equal to 0, first m is assigned the value of n, and then n is assigned the value of r. We
express this in Musimat by making these two steps into a compound statement.
Any legal statement can appear within a compound statement, including other compound state-
ments. This means we can nest compound statements inside each other.
*****************************************************************************/
}
1.7.2