• Main Page
  • Files
  • File List
  • File Members

/Users/garethloy/Musimathics/Musimat1.2/MusimatTutorial/B0111.cpp

Go to the documentation of this file.
00001 #include "MusimatTutorial.h"
00002 MusimatTutorialSection(B0111) {
00003         Print("*** B.1.11 Logical Operations ***");
00004         /*****************************************************************************
00005          
00006          B.1.11 Logical Operations
00007          
00008          Logical operators compare truth values. For example, the expression x And y is True if and only 
00009          if x == True and y == True. The expression x Or y is True if either x == True or 
00010          y == True.
00011          *****************************************************************************/
00012         
00013         Bool applesAreRed = True;
00014         Bool bananasAreYellow = True;
00015         Bool nightIsDay = False;
00016 
00017         Print("applesAreRed And bananasAreYellow is ", applesAreRed And bananasAreYellow); // prints 1
00018         Print("applesAreRed And nightIsDay is ", applesAreRed And nightIsDay); // prints 0
00019         
00020         Print("applesAreRed Or bananasAreYellow is ", applesAreRed Or bananasAreYellow); // prints 1
00021         Print("applesAreRed Or nightIsDay is ", applesAreRed Or nightIsDay); // prints 1
00022 
00023         /*****************************************************************************
00024          
00025          B.1.11 Logical Operations
00026          
00027          We can invert the sense of a Bool expression with the operator "!".
00028          *****************************************************************************/
00029         
00030         Print("!applesAreRed is ", !applesAreRed); // prints 0
00031         
00032         Print("applesAreRed Or !bananasAreYellow is ", applesAreRed Or !bananasAreYellow); // prints 1
00033         Print("!applesAreRed Or nightIsDay is ", applesAreRed Or !nightIsDay); // prints 1
00034 
00035         
00036 }
00037 
00039 /* $Revision: 1.2 $ $Date: 2006/09/05 06:32:25 $ $Author: dgl $ $Name:  $ $Id: B0111.cpp,v 1.2 2006/09/05 06:32:25 dgl Exp $ */
00040 // The Musimat Tutorial � 2006 Gareth Loy
00041 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" � 2006 Gareth Loy 
00042 // and published exclusively by The MIT Press.
00043 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00044 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00045 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00046 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00047 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00048 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00049 // The Musimat website:                 http://www.musimat.com/
00050 // This program is released under the terms of the GNU General Public License
00051 // available here:                      http://www.gnu.org/licenses/gpl.txt
00052 

Generated on Fri Nov 26 2010 16:18:25 for Musimat Tutorial by  doxygen 1.7.2