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.

(If you have forgotten about closures, please revisit Lecture 2.)

We discussed higher-order functions. A function that takes another function as an argument is classified as a higher-order function, as are functions that return functions. (Some authors narrow the definition to restrict returns to higher-order functions, so that currying or uncurrying a function does not change its order.)

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 filter, map, foldl, and foldr.

Key Concepts

Sample Code

Some Notes on Higher-Order Functions

Here is some extra material about folding:   How to Fold, along with code.

Lecture Slides

Lecture Slides with every build, use "slideshow" option in your pdf viewer. Lecture Slides compact.