15-150: Principles of Functional Programming

Lecture 10: Higher-Order Functions

We defined what it means to curry a function and how to write curried functions in SML.

We reviewed closures (code and environment) and how bindings of function values to identifiers occur.
If you have forgotten, please revisit Lecture 2.

We discussed higher-order functions. A function for which at least one argument type is itself a function type is classified as a higher-order function, as are functions that return higher-order functions. (Some authors broaden the definition to also include any function that returns a first-order function.)

We discussed passing functions as arguments, returning functions as values, and mapping functions over recursive data structures. Key to understanding functions as first class values is understanding the lexical scoping rules.

We discussed several important higher-order functions on lists, including map, foldl, and foldr.

Key Concepts

Sample Code

Some Notes on Higher-Order Functions

How to Fold, along with code

Code generated during the live-coding session in the 3pm lecture