Higher Order Functions

A higher-order function must take one or more functions as an input and/or return a function as its value. Clojure's functions have both of these capabilities.

Functions as Inputs

Many programmers rely heavily on the first capability, eg:

The map function, found in many functional programming languages, is one example of a higher-order function. It takes as arguments a function f and a list of elements, and as the result, returns a new list with f applied to each element from the list. Another very common kind of higher-order function in those languages which support them are sorting functions which take a comparison function as a parameter, allowing the programmer to separate the sorting algorithm from the comparisons of the items being sorted. ...

-- http://en.wikipedia.org/wiki/Higher-order_function

Functions as Return Values

The second capability (returning anonymous functions as values) is a programming staple in many modern scripting languages (eg, JavaScript, Python, Ruby).

Higher-order functions are less common in older, imperative languages. However, anonymous functions (ie, lambda expressions) are slated for inclusion in Java Version 8.


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r1 - 05 Mar 2013, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email