15-150: Principles of Functional Programming

Lecture 4: Recursion and Structural Induction on Lists, Tail Recursion

We introduce SML's predefined list datatype for integers.

We show how to prove theorems about lists using structural induction.

We discuss tail recursion, a form of recursion that is somewhat like the use of loops in imperative programming. This form of recursion is often used to make functions more efficient. Accumulator arguments play an important role in tail recursion. The presences of an accumulator argument in a function forces us to think carefully about the specification of the function and to prove corresponding theorems of correctness.

Key Concepts

Sample Code

Some Notes on Structural Induction