Difference between revisions of "First-class function"
Karl Jones (Talk | contribs) |
Karl Jones (Talk | contribs) (→External links) |
||
Line 32: | Line 32: | ||
* [https://en.wikipedia.org/wiki/First-class_function First-class function] @ Wikipedia | * [https://en.wikipedia.org/wiki/First-class_function First-class function] @ Wikipedia | ||
+ | |||
+ | [[Category:Computer programming]] | ||
+ | [[Category:Computer science]] |
Revision as of 04:25, 22 April 2016
In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens.
Description
Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.
Some programming language theorists require support for anonymous functions (function literals) as well.
In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type.
The term was coined by Christopher Strachey in the context of "functions as first-class citizens" in the mid-1960s.
Functional programming
First-class functions are a necessity for the functional programming style, in which the use of higher-order functions is a standard practice.
A simple example of a higher-ordered function is the map function, which takes, as its arguments, a function and a list, and returns the list formed by applying the function to each member of the list.
For a language to support map, it must support passing a function as an argument.
See also
- Computer program
- Computer programming
- Computer science
- First-class citizen
- Function_(mathematics)
- Programming language
- Subroutine
External links
- First-class function @ Wikipedia