Learning a programming language involves learning about the types of data and the types of control structures that the language provides. To this point, the only types of data that we have studied have been integers and floating-point numbers. Instead, we have concentrated on learning about ever more complicated control structures. We began with simple straight-line programs, and then added functions, conditionals, and loops.
In this lesson we will add a new type of data to our mix by studying arrays, which provide a way of combining many individual variables into a single aggregate collection. This makes it possible to write small programs that nevertheless manipulate a large number of variables. This is a crucial addition to our language, because it can take a large number of variables to model the behavior of the natural world. To motivate the utility of arrays, we will study the problem of one-dimensional heat flow in a rod.
All of the programs contained in this lesson can also be copied to your examples directory.
Click to copy the example programs.