Chapter 1
Introducing functional programming




I feel that the matter of design is a most important point to stress right from the start of any functional programming course. A common complaint amongst students is that they find it hard just to get going on writing a function definition, so giving them strategies such as modifying, simplifying, generalising or using other functions gives one kind of handle on the task.


Calculation gives a concrete model of how functional programs work; this can help students who find it difficult to appreciate how a definition works. I try to encourage students to try examples as another strategy when they are stuck. (Later in the text examples are used to guide the way that definitions are written.)

Links with imperative programming

Obviously students come from different backgrounds. Appendix A provides a commentary on the relationship between Pascal-style imperative programming and Miranda. It is very useful to make these distinctions, both about issues like syntax (especially the different ways that function calls are written) and terminology (what is a function in the two cases?) as well as about the different ways that problems are tackled in the different languages. At Kent we have tried as much as we can to link our functional and imperative programming presentations; this comes into its own when looking at dynamic data structures, but can be useful right from the start.


This is a good point at which to introduce some of the other appendices, especially the glossary and the list of error messages. Also included is the standard environment; it is worth mentioning this, but making clear that some of the notations there will not be fully explained until Part II of the text.


The first example file, as well as all the code from the text is available by clicking on the title of this paragraph.

Next Up

Written 18 May 1995.