Higher-order function
Function that takes one or more functions as an input or that outputs a function
title: "Higher-order function" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["functional-programming", "lambda-calculus", "higher-order-functions", "subroutines", "articles-with-example-c-code", "articles-with-example-c++-code", "articles-with-example-d-code", "articles-with-example-haskell-code", "articles-with-example-java-code", "articles-with-example-javascript-code", "articles-with-example-julia-code", "articles-with-example-lisp-(programming-language)-code", "articles-with-example-matlab/octave-code", "articles-with-example-pascal-code", "articles-with-example-perl-code", "articles-with-example-php-code", "articles-with-example-python-(programming-language)-code", "articles-with-example-r-code", "articles-with-example-scala-code", "articles-with-example-scheme-(programming-language)-code", "articles-with-example-tcl-code", "articles-with-example-swift-code"] description: "Function that takes one or more functions as an input or that outputs a function" topic_path: "science/mathematics" source: "https://en.wikipedia.org/wiki/Higher-order_function" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Function that takes one or more functions as an input or that outputs a function ::
- takes one or more functions as arguments (i.e. a procedural parameter, which is a parameter of a procedure that is itself a procedure),
- returns a function as its result. All other functions are first-order functions. In mathematics higher-order functions are also termed operators or functionals. The differential operator in calculus is a common example, since it maps a function to its derivative, also a function. Higher-order functions should not be confused with other uses of the word "functor" throughout mathematics, see Functor (disambiguation).
In the untyped lambda calculus, all functions are higher-order; in a typed lambda calculus, from which most functional programming languages are derived, higher-order functions that take one function as argument are values with types of the form (\tau_1\to\tau_2)\to\tau_3.
General examples
- function, found in many functional programming languages, is one example of a higher-order function. It takes arguments as a function f and a collection of elements, and as the result, returns a new collection with f applied to each element from the collection.
- , which take a comparison function as a parameter, allowing the programmer to separate the sorting algorithm from the comparisons of the items being sorted. The C standard function
qsortis an example of this. - (including and )
- Function composition
- Integration
- Callback
- Tree traversal
- Montague grammar, a semantic theory of natural language, uses higher-order functions
References
References
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::