20.03.2013 Views

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NOTES ON DATA STRUCTURING 103<br />

else deal with single character<br />

end<br />

else begin deal with single character;<br />

read next character<br />

)<br />

end<br />

until end of tape<br />

4. THE CARTESIAN PRODUCT<br />

Defined enumerati<strong>on</strong>s and subranges, like primitive data types, are in principle<br />

unstructured. Of course, any particular representati<strong>on</strong> of these types will be<br />

structured, for example, as a collecti<strong>on</strong> of c<strong>on</strong>secutive binary digits; but<br />

from the abstract point of view, this structuring is essentially irrelevant. No<br />

operators are provided for accessing the individual bits, or for building up a<br />

value from them. In fact, it is essential to the successful use of an abstracti<strong>on</strong><br />

that such a possibility should be ignored; since it is <strong>on</strong>ly thus that detailed<br />

decisi<strong>on</strong>s can be postp<strong>on</strong>ed, and data representati<strong>on</strong>s can be decided in the<br />

light of the characteristics of the computer, as well as the manner in which<br />

the data is to be manipulated.<br />

We now turn to deal with data types for which the structure is meaningful<br />

to the programmer, at least at some stage in the development of his program.<br />

The basis of our approach is that, as in the case of enumerati<strong>on</strong>s, the pro-<br />

grammer should be able by declarati<strong>on</strong> to introduce new data types; but for<br />

structured data, the definiti<strong>on</strong> of a new type will refer to other primitive or<br />

previously defined types, namely the types of the comp<strong>on</strong>ents of the structure.<br />

Thus the declarati<strong>on</strong> of a new type will be somewhat similar to the declara-<br />

ti<strong>on</strong> of a new functi<strong>on</strong> in a language such as ALGOL and FORTRAN. A<br />

functi<strong>on</strong> declarati<strong>on</strong> defines the new functi<strong>on</strong> in terms of existing or pre-<br />

viously declared functi<strong>on</strong>s and operati<strong>on</strong>s. Just as a declared functi<strong>on</strong> can be<br />

invoked <strong>on</strong> many occasi<strong>on</strong>s from within statements of the program or other<br />

functi<strong>on</strong> declarati<strong>on</strong>s, so the new type can be "invoked" many times from<br />

within other declarati<strong>on</strong>s of the program; these may be either declarati<strong>on</strong>s<br />

of variables specified to range over the newly declared type, or they may be<br />

declarati<strong>on</strong>s of yet another new type.<br />

We will deal first with elementary data structures, Cartesian products and<br />

uni<strong>on</strong>s. These elementary structures are almost as simple and familiar to<br />

mathematicians and logicians as the natural numbers. Furthermore, from

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!