15-150: Principles of Functional Programming
Lecture 5: Datatypes, Recursion and Structural Induction on Trees
We introduced datatype declarations as a form of abstraction designed
to relieve a programmer from the burden of keeping track of low-level
hacking conventions.
We considered the predefined datatype
order with constant constructors LESS,
EQUAL, GREATER.
We made up some of our own
datatypes, including a datatype to model the extended integers, two
different tree datatypes, and a datatype for operator-operand trees.
We showed how to prove theorems about trees using structural induction.
Key Concepts
- datatype declarations
- constant constructors
- constructors that take arguments
- recursively defined types
- tree types
- correspondence between recursive datatype, recursive function
clauses, and proof by structural induction
(Today's lecture at 12:30pm was supposed to be a blackboard lecture,
and occurred online as a written lecture, so there are no slides for
today's lecture.)