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. ...
Functions as Return Values
The second capability (returning anonymous functions as values)
is a programming staple in many modern scripting languages
Higher-order functions are less common in older, imperative languages.
However, anonymous functions
(ie, lambda expressions) are slated for inclusion
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!