1
$\begingroup$

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

$\endgroup$
4
  • 1
    $\begingroup$ not sure why forum has made two minuses for this question. A considerable amount of knowledge sharing been happened, so IMO this post not deserve -2 $\endgroup$
    – nish1013
    Jul 31, 2013 at 12:44
  • 2
    $\begingroup$ Good answers doesn't mean good question. You could have found the answer easily by googling for lambda notation history, e.g. math.stackexchange.com/q/64468. $\endgroup$
    – Kaveh
    Aug 2, 2013 at 6:16
  • $\begingroup$ @Kaveh If you carefully read the question , you would notice the question is in the programming context not in mathematics. And people won't get same question in their head even they might lead to a same answer. On the other hand it is intellectually not fair to categories questions as bad or good , and as most would agree a question would NEVER be bad. $\endgroup$
    – nish1013
    Aug 2, 2013 at 8:05
  • $\begingroup$ I have read the question. You seem to be new to Stack Exchange. I haven't down voted your question, I just explained why your question has got 4 down votes and 1 close vote. On cstheory a question can be considered bad for several reasons, e.g. when the answer can be found easily by searching as is in this case. I would suggest you check help center. $\endgroup$
    – Kaveh
    Aug 2, 2013 at 8:22

3 Answers 3

7
$\begingroup$

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.

$\endgroup$
7
  • 1
    $\begingroup$ Great explanation, many thanks for that."λx.xx applies the functional argument x to itself." does this mean if x ==2 , then return is 4? or you meant something else? $\endgroup$
    – nish1013
    Jul 24, 2013 at 11:13
  • 1
    $\begingroup$ could you please suggest a resource such as a book to gather knowledge for Lambda Calculus (in perspective of programming) ? I have seen many advance book that could make someone really tired ! $\endgroup$
    – nish1013
    Jul 24, 2013 at 11:21
  • 1
    $\begingroup$ λx.xx, or rather λx.(x x), means "apply x to x." Or think of it as x(x). For example, if arg = λx.(x x), then (λx.(x x) arg) = (λx.(x x) λx.(x x)), which has reached a fixed point. It can't be simplified further. Here the argument is a function and the return result is an application. Note that application is as important as function in lambda calculus. $\endgroup$
    – Zirui Wang
    Jul 24, 2013 at 13:16
  • 1
    $\begingroup$ Oh I see lets say I want to convert following function into lambda, public int sum(int x , int Y){ return x+y; } what would be the representation using lambda? $\endgroup$
    – nish1013
    Jul 24, 2013 at 13:22
  • 1
    $\begingroup$ λxy.(+ x y). Here + is a function and it's applied to two arguments. $\endgroup$
    – Zirui Wang
    Jul 25, 2013 at 15:40
6
$\begingroup$

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

$\endgroup$
5
$\begingroup$

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".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.