C:/Musimathics_local/Musimat/MusimatTutorial/B0109.cpp File Reference

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0109)


Function Documentation

MusimatTutorialSection ( B0109   ) 

Definition at line 2 of file B0109.cpp.

00002                               {
00003 Print("*** B.1.9 Assignment ***");
00004 /*****************************************************************************
00005 
00006 B.1.9 Assignment
00007 
00008 We can assign the value of an expression to a variable using the assignment operator =. For example,
00009 
00010 lhs = rhs;
00011 
00012 assigns the expression rhs to lhs. The object on the right-hand side of the = sign (i.e., rhs) can 
00013 be any expression. The object on the left-hand side (i.e., lhs) must be a variable name, with one 
00014 exception. For example, the statement
00015 
00016 s = 3 + 5;
00017 
00018 sets the value of variable s to 8.
00019 
00020 The left-hand side of an assignment can also indicate that a certain element of a list is to receive 
00021 the value on the right-hand side. For example,
00022 *****************************************************************************/
00023 
00024 IntegerList iL(0, 1, 2, 3);
00025 
00026 iL[2] = 10;
00027 
00028 /*****************************************************************************
00029 replaces the third element with 10, causing the list to become
00030 
00031 {0, 1, 10, 3}
00032 
00033 Note that lists are indexed starting at 0. So writing
00034 *****************************************************************************/
00035 
00036 iL[0] = 55;
00037 
00038 /*****************************************************************************
00039 causes the list to be {55, 1, 10, 3} which we can see by printing it:
00040 *****************************************************************************/
00041 
00042 Print( iL );
00043 
00044 }}


Generated on Fri Sep 8 00:53:00 2006 for MusimatLib by  doxygen 1.4.7