6.1.2 Compound Data

Compound data is data that one can subdivide into smaller pieces of data and organize it in a particular way. An example of compound data is a list. A list consists of several pieces of data which have a specific ordering. The data items that comprise a piece of compound data may themselves be either compound or atomic. For example, we could imagine a list of numbers. The list itself is compound data, while each piece of data in the list is atomic data. We could also imagine a list of lists of numbers. In such a case, the list of lists is compound data, and each piece of data in the list is itself an example of compound data whose individual pieces are, in turn, atomic data.

Don’t worry too much if the notion of “list of lists” makes your head hurt! We’ll revisit the idea of compound data in more detail later. For now, the only type of compound data we will be using are strings.