Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Lambda calculus
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Anonymous functions === {{Further|Anonymous function}} For example, in [[Python (programming language)|Python]] the "square" function can be expressed as a lambda expression as follows: <!-- Please do not add the same example in different languages to this article, see Anonymous function for that. Thank you! --> <syntaxhighlight lang="Python"> (lambda x: x**2) </syntaxhighlight> The above example is an expression that evaluates to a first-class function. The symbol <code>lambda</code> creates an anonymous function, given a list of parameter names, <code>x</code> β just a single argument in this case, and an expression that is evaluated as the body of the function, <code>x**2</code>. Anonymous functions are sometimes called lambda expressions. For example, [[Pascal (programming language)|Pascal]] and many other imperative languages have long supported passing [[Function (computer programming)|subprograms]] as [[Parameter (computer programming)|arguments]] to other subprograms through the mechanism of [[function pointer]]s. However, function pointers are an insufficient condition for functions to be [[First-class function|first class]] datatypes, because a function is a first class datatype if and only if new instances of the function can be created at [[Execution (computing)#runtime|runtime]]. Such runtime creation of functions is supported in [[Smalltalk]], [[JavaScript]], [[Wolfram Language]], and more recently in [[Scala (programming language)|Scala]], [[Eiffel (programming language)|Eiffel]] (as agents), [[C Sharp (programming language)|C#]] (as delegates) and [[C++11]], among others.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)