I have recently heard people talk about code being "lambda". I have never heard of this phrase before. What does it mean?

  • It did. Several times. I even tried it a few times - but sadly with no success. Maybe you'll have more luck? Thanks to those who repsonded. Apr 12 '11 at 12:25
  • 10
    @Oliver, part of asking a question here is to also show what have you done to answer that question so that people aren't trying the same things you did and get stuck. By specifying where in the Wikipedia or Google links you found you were confused this ensures your question gets better answered as at a general level the answer may not be what you wanted since it is just referencing what you didn't get previously. Just consider trying what someone else is posting and see what happens. You may be surprised at what results.
    – JB King
    Apr 12 '11 at 14:39
  • 7
    I sense a rap could be made out of this - "my code so lambda". But I can't rhythm it worth anything. :-) Apr 12 '11 at 15:39
  • 1
    @JB King + JB King - Thank you for your courteous comments. In broad terms, what you both say is sensible. However, depending on the query, sometimes a brief and open question is better at eliciting the kinds of replies that are not found elsewhere. My question elicited precisely the kind of answers that I was looking for. I phrased it so that it would. I hope the answers below are useful to others with the same question. It's ironic that I am satisfied with the answers at the same time that some are disappointed with the question. Apr 12 '11 at 15:43
  • 2
    @Paul Nathan - you're code so lambda you clearly never planned ta work to any standard; it's rougher than a sander!
    – glenatron
    Apr 12 '11 at 15:50

Lambda expressions are either an abstraction (sometimes referred to as anonymous function), an application or a variable (most languages also add constants to this list). Lambda terms are not necessarily functions, and not necessarily passed as parameters, though this is a common practice.

A common example of lambda expressions in C#

For example:

List<int> items = new List<int>();

int CountofOnes = items.FindAll(item => item == 1).Count();


will output: 2

In this code, I pass a lambda construction to the FindAll function of .NET's List object.

items.FindAll(item => item == 1)

The lambda in this call executes a simple equation and returns a boolean, telling FindAll what to do.

  • 2
    That's not quite true. Lambda expression is either an abstraction (not necessarily small), an application or a variable (most languages also add constants to this list). Lambda terms are not necessarily functions, and not necessarily passed as parameters.
    – SK-logic
    Apr 12 '11 at 12:14
  • You're right, i will ammend the answer for the sake of clarity. Apr 12 '11 at 12:17
  • 3
    Give me an example of a lambda expression that is not a function, please.
    – Ingo
    Apr 12 '11 at 12:28
  • 1
    @Ingo, this is a terminology of lambda calculus, of course. en.wikipedia.org/wiki/Lambda_calculus#Lambda_terms
    – SK-logic
    Apr 12 '11 at 12:54
  • 1
    @SK-logic I prefer to see it differently. Languages like Haskell and C# make it possible to bind functions to names in a let (rec) construct or in the form of "super-combinators" (i.e. top level function bindings), and this I see as such a grave difference that I do not feel it is right to apply the original lambda terminology here. Because no such thing is possible in LC (thats precisely why you need an Y combinator for recursion). The result of ((\x y -> x) a) and (const a) in Haskell is the same and both are applications, but I would only the first term as "lambda application".
    – Ingo
    Apr 12 '11 at 14:57

Anonymous (unnamed) function or an object that is usually inlined as an argument to another function.

Hence, the namespace is less polluted.


Lambda usually refers to a function expression in a functional programming context.

This is a lambda expression in python:

lambda x: x + 1

Represents a function that increments its parameter x by 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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