Content deleted Content added
→List of languages: +Typst |
Updated short description Tags: Reverted Mobile edit Mobile app edit Android app edit App description change |
||
Line 1:
{{short description|
In [[computer programming]], an '''anonymous function''' ('''function literal''', '''expression''' or '''block''') is a [[Function (computer science)|function]] definition that is not [[name binding|bound]] to an [[Name (computer science)|identifier]]. Anonymous functions are often arguments being passed to [[higher-order function]]s or used for constructing the result of a higher-order function that needs to return a function.<ref>{{cite web |title=Higher order functions |url=http://learnyouahaskell.com/higher-order-functions |access-date=3 December 2014 |website= |publisher=learnyouahaskell.com |language=en-US}}</ref>
If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in [[functional programming language]]s and other languages with [[first-class function]]s, where they fulfil the same role for the [[function type]] as [[literal (computer programming)|literals]] do for other [[data type]]s.
Line 5:
Anonymous functions originate in the work of [[Alonzo Church]] in his invention of the [[lambda calculus]], in which all functions are anonymous, in 1936, before electronic computers.<ref>{{citation|title=Models of Computation: An Introduction to Computability Theory|series=Undergraduate Topics in Computer Science|first=Maribel|last=Fernandez|publisher=Springer Science & Business Media|year=2009|isbn=9781848824348|page=33|url=https://books.google.com/books?id=FPFsnzzebhQC&pg=PA33|quote=The Lambda calculus ... was introduced by Alonzo Church in the 1930s as a precise notation for a theory of anonymous functions}}</ref> In several programming languages, anonymous functions are introduced using the keyword ''lambda'', and anonymous functions are often referred to as lambdas or lambda abstractions. Anonymous functions have been a feature of [[programming language]]s since [[Lisp (programming language)|Lisp]] in 1958, and a growing number of modern programming languages support anonymous functions.
{{toclimit|3}}
== Names ==
The names "lambda abstraction", "lambda function", and "lambda expression" refer to the notation of function abstraction in lambda calculus, where the usual function {{math|1={{itco|''f''}}(''x'') = ''M''}} would be written {{math|1=(λ''x''.{{itco|''M''}})}}, and where {{mvar|M}} is an expression that uses {{mvar|x}}. Compare to the Python syntax of <syntaxhighlight lang=python inline>lambda x: M</syntaxhighlight>.
|