First-class function

In computer science, a programming language is said to have first-class functions if it treatsfunctions as first-class citizens. 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.[1] Some programming language theorists require support for anonymous functions (function literals) as well.[2] In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinaryvariables with a function type.[3] The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960s.[4]

First-class functions are a necessity for the functional programming style, in which the use ofhigher-order functions is a standard practice. A simple example of a higher-ordered function is themap 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.

https://en.wikipedia.org/wiki/First-class_function

Leave a Reply

Close Menu