Chapter 3
Higher-Order Functions

Overview
Although functions are arguably the most important concept in mathematics, functions are not generally available as (first-class) values in all programming languages. The exceptions are, of course, the languages that derive their collective name from functions: the functional languages. After a short introduction to functional languages, this chapter concentrates on higher-order functions: functions that take other functions as arguments or return functions as results. This possibility allows for a number of fascinating applications, ranging from useful to esoteric.

After an introduction to functional programming, Section 2 discusses the functional features of Mathematica. Next, we treat higher-order functions and their applications, such as mapping and folding, and we show how procedural control structures can be replaced by functional code. The last section is about a more theoretical aspect of functions: fixed-point operators and the theory of complete partial orders. These concepts can be realized in Mathematica and we can give simple examples of their usefulness.

The initial effort required to get acquainted with the notion of functions as values is well worth it. Thinking functionally, we can solve a range of problems far more elegantly than with the usual loop, which we often use first, without thinking, due to the lopsided introduction to programming to which most of us were subjected. Mathematica offers both worlds and is an ideal vehicle for experiments in programming style. This chapter shows some of the not-so-obvious uses of higher-order functions. It shows that programs themselves are values that can be manipulated by other programs.

Programs
Y.m
Resources on the Internet
FAQ
A list of frequently asked questions (and the answers) about functional programming.

Top Up Next Internet Updates

Rev. 1.0, REM, © 1996 Roman E. Maeder