15-150: Principles of Functional Programming

Lecture 11: Higher-Order Functions (continued)

We continue our discussion of higher-order functions:

We discuss combinators. Combinators are higher-order functions that lift operations from a type to functions with values in that type. Combinators are defined using the pointwise principle. Currying makes this easy in SML.

We discuss staging. Staging takes advantage of the nested lambda form of a curried function to move parts of a computation close to the place where the arguments required for the computation appear. This can save computation time in a function that can do some of its work as soon as it sees its first argument, for instance. When called several times with the same first argument and different second arguments, the function can reuse the results of these early partial computations.

We generalize some higher-order list functions to trees.

Key Concepts

Sample Code

More notes on higher-order functions

See also again the notes from last time on higher order functions, particularly for the generalization to trees.