could any one please let me know what is the relation between "lambda" and anonymous functions in programming?
in other words why we say lambda function to an anonymous function?
I am here trying to understand the reason for use of the term
could any one please let me know what is the relation between "lambda" and anonymous functions in programming?
in other words why we say lambda function to an anonymous function?
I am here trying to understand the reason for use of the term
There is a popular formal system called Lambda calculus. It is Turing complete and has great importance in the theory of programming languages. Lambda calculus is based on anonymous functions with very simple syntax. You start a new function with a $\lambda$, list the arguments, place a dot, and write down the return value. For example, $\lambda x.x$ is the identity function, $\lambda x.xx$ applies the functional argument $x$ to itself.
Since programming language designers know Lambda calculus very well, it seemed like a good idea to call anonymous functions in their language lambdas.
By the way, why did Church choose the notation “λ”? In [Church, 1964, §2] he stated clearly that it came from the notation “xˆ” used for class-abstraction by Whitehead and Russell, by first modifying “xˆ” to “∧x” to distinguish function- abstraction from class-abstraction, and then changing “∧” to “λ” for ease of printing. This origin was also reported in [Rosser, 1984, p.338]. On the other hand, in his later years Church told two enquirers that the choice was more accidental: a symbol was needed and “λ” just happened to be chosen.
-- History of Lambda-Calculus and Combinatory logic, F. Cardone and J. R. Hindley, 2009
The reason lambda is used is because of the lambda-calculus, where λx.E (for any expression E) is used to denote the function which takes a value a and returns E[a/x], meaning "the result of substituting a for x in E". Thus, (λx.x+1)(5) = 5+1 = 6.
This however doesn't answer the question why specifically λ was chosen for this role. The answer requires a little bit of history, but if you're interested, here it is.
In the Principia Mathematica, the notation "ẑP(z)" was introduced for "the set of all z such that P(z)" (which we would now write as {z:P(z)}). The notation was quite popular for a while after, and hence was the one Alonzo Church (the creator/discoverer of the λ-calculus) was familiar with.
Alonzo Church, was interested in a view of mathematics where sets were interpreted as functions from individuals to truth-values. Thus rather than writing 6 ∈ ẑ(z > 5), we could just write "[ẑ(z > 5)](6)", which would have the same value as "(6 > 5)", and hence TRUE. Viewed this way, there should be no difference between an expression like "ẑ(z > 5)" and "ẑ(z+5)", as they both represent functions which can accept values. "[ẑ(z + 5)](6)" would then have the same value as "(6+5)", which is 11.
The long and short of it is, when he first started writing papers on the formal properties of these systems, there were some difficulties with typesetting "ẑ", so "ẑ" became "^z", which then became "λz" for stylistic reasons.
Later, when students would ask him how he decided on the letter "λ", he used to claim "eenie meanie minee moe".