#include "MusimatTutorial.h"Go to the source code of this file.
Functions | |
| MusimatTutorialSection (B0117) | |
| MusimatTutorialSection | ( | B0117 | ) |
Definition at line 2 of file B0117.cpp.
00002 { 00003 Print("*** B.1.17 Compound Statements ***"); 00004 /***************************************************************************** 00005 00006 B.1.17 Compound Statements 00007 00008 Suppose we need to do more than one thing depending on the value of a predicate. If we need to execute 00009 multiple statements that depend upon a common predicate, we can group them together into a list of 00010 statements. For example, {m = n; n = r;} is a list of statements, also called a compound state- 00011 ment. Consider steps 2 and 3 of Euclid’s method (see section 9.2.2), which can be expressed: 00012 *****************************************************************************/ 00013 00014 Integer m, n = 1, r = 1; 00015 00016 If (r == 0) 00017 Halt(n); 00018 Else { 00019 m = n; 00020 n = r; 00021 } 00022 00023 /***************************************************************************** 00024 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 00025 express this in Musimat by making these two steps into a compound statement. 00026 00027 Any legal statement can appear within a compound statement, including other compound state- 00028 ments. This means we can nest compound statements inside each other. 00029 00030 *****************************************************************************/ 00031 }}
1.4.7