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 ::

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 qsort is 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

  1. "PHP: Arrow Functions - Manual".

::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. ::

functional-programminglambda-calculushigher-order-functionssubroutinesarticles-with-example-c-codearticles-with-example-c++-codearticles-with-example-d-codearticles-with-example-haskell-codearticles-with-example-java-codearticles-with-example-javascript-codearticles-with-example-julia-codearticles-with-example-lisp-(programming-language)-codearticles-with-example-matlab/octave-codearticles-with-example-pascal-codearticles-with-example-perl-codearticles-with-example-php-codearticles-with-example-python-(programming-language)-codearticles-with-example-r-codearticles-with-example-scala-codearticles-with-example-scheme-(programming-language)-codearticles-with-example-tcl-codearticles-with-example-swift-code