- Main Page
- Namespaces
- Files

- File List
- File Members

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

Go to the documentation of this file.

    00001 #include "MusimatTutorial.h"
    00002 MusimatTutorialSection(B0114) {
    00003 Print("*** B.1.14 Accessing List Elements ***");
    00004 /*****************************************************************************
    00005
    00006 B.1.14 Accessing List Elements
    00007
    00008 We can access an element of a list using the index operator []. Suppose we have the following
    00009 declarations:
    00010 *****************************************************************************/
    00011
    00012 Integer w = 1, x = 2, y = 3, z = 4;
    00013 IntegerList iL(w, x, y, z);
    00014
    00015 /*****************************************************************************
    00016 Then the statement
    00017 *****************************************************************************/
    00018
    00019 Integer c = iL[0];
    00020
    00021 /*****************************************************************************
    00022 assigns c the same value as w (which is 1). The statement
    00023 *****************************************************************************/
    00024
    00025 c = iL[3];
    00026
    00027 /*****************************************************************************
    00028 assigns c the same value as z (which is 4).
    00029
    00030 The first element on a list is indexed by 0, and if a List has N elements, the last one is indexed
    00031 by N - 1.
    00032
    00033 *****************************************************************************/
    00034 }}
    00035
    00037 /* $Revision: 1.1 $ $Date: 2006/09/08 19:11:31 $ $Author: dgl $ $Name:  $ $Id: _b0114_8cpp-source.html,v 1.1 2006/09/08 19:11:31 dgl Exp $ */
    00038 // The Musimat Tutorial © 2006 Gareth Loy
    00039 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00040 // and published exclusively by The MIT Press.
    00041 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00042 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00043 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00044 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00045 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00046 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00047 // The Musimat website:                 http://www.musimat.com/
    00048 // This program is released under the terms of the GNU General Public License
    00049 // available here:                      http://www.gnu.org/licenses/gpl.txt
    00050