- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatTutorial/B0117.cpp

Go to the documentation of this file.

    00001 #include "MusimatTutorial.h"
    00002 MusimatTutorialSection(B0117) {
    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 }}
    00032
    00034 /* $Revision: 1.2 $ $Date: 2006/09/09 06:23:08 $ $Author: dgl $ $Name:  $ $Id: _b0117_8cpp-source.html,v 1.2 2006/09/09 06:23:08 dgl Exp $ */
    00035 // The Musimat Tutorial © 2006 Gareth Loy
    00036 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00037 // and published exclusively by The MIT Press.
    00038 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00039 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00040 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00041 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00042 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00043 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00044 // The Musimat website:                 http://www.musimat.com/
    00045 // This program is released under the terms of the GNU General Public License
    00046 // available here:                      http://www.gnu.org/licenses/gpl.txt
    00047