🌐
W3Schools
w3schools.com › python › python_lambda.asp
Python Lambda
A lambda function is a small anonymous function.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › what is aws lambda?
What is AWS Lambda? - AWS Lambda
January 31, 2026 - You write and organize your code in Lambda functions, which are the basic building blocks you use to create a Lambda application.
Discussions

I still don't understand the benefit of lambda functions
they're just...functions with different syntax That's exactly what they are. The main syntactical difference between the two is that a regular function definition is a statement, whereas a lambda function definition is an expression. Lambda functions can therefore be defined and then passed to another function in one step, without having to go through a local name (that's also why lambda functions are sometimes called anonymous functions, they don't necessarily have a particular name). Lambda is a convenience feature to more easily define small, one-off functions. More on reddit.com
🌐 r/learnpython
118
320
January 23, 2022
language agnostic - What is a lambda (function)? - Stack Overflow
For a person without a comp-sci background, what is a lambda in the world of Computer Science? More on stackoverflow.com
🌐 stackoverflow.com
What is the purpose of Lambda expressions?
This is a typical example for beginners: x=lambda n:2*n print(x(7)) Otherwise I would create a function: def dbl(n): return 2*n print(dbl(7)) Of course: I can write simply 2*7, but the idea is to save a complex formula in an object once, and reuse it several times. More on discuss.python.org
🌐 discuss.python.org
19
1
December 8, 2021
Lambda function
map applies a function to every element of an iterable. Sometimes these functions are very simple operations; for example, if I wanted to double every number in a list. It's wasteful to define an entire new function (with the def keyword) just for this one simple operation. Lambda creates a callable function that we can use. Here's an example of how we could create that and use it with map. numbers = [1, 5, 20, 50] map(lambda x:x * 2, numbers) More on reddit.com
🌐 r/learnpython
24
11
April 1, 2024
🌐
Microsoft Support
support.microsoft.com › en-us › office › lambda-function-bd212d27-1cd1-4321-a34a-ccbf254b8b67
LAMBDA function - Microsoft Support
You can create a function for a commonly used formula, eliminate the need to copy and paste this formula (which can be error-prone), and effectively add your own functions to the native Excel function library. Furthermore, a LAMBDA function doesn't require VBA, macros or JavaScript, so non-programmers can also benefit from its use.
function definition that is not bound to an identifier
In computer programming, an anonymous function (function literal, lambda function, or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order … Wikipedia
🌐
Wikipedia
en.wikipedia.org › wiki › Anonymous_function
Anonymous function - Wikipedia
February 18, 2026 - In computer programming, an anonymous function (function literal, lambda function, or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function ...
🌐
W3Schools
w3schools.com › cpp › cpp_functions_lambda.asp
C++ Lambda Functions
It's useful when you need a quick function without naming it or declaring it separately. ... Don't worry: We'll explain what [capture] means later. For now, let's just use an empty pair of brackets. Here, message holds a lambda function that prints a message to the screen:
🌐
Codecademy
codecademy.com › article › python-lambda-function
Python Lambda Functions Explained (With Examples) | Codecademy
Dive deeper into the unique ways to utilize functions to create cleaner and more efficient software. ... A Python lambda function is an anonymous function that lets you write quick, inline functions without using the def keyword.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-lambda-anonymous-functions-filter-map-reduce
Python Lambda Functions - GeeksforGeeks
Lambda functions are small anonymous functions, meaning they do not have a defined name.
Published   2 weeks ago
Top answer
1 of 16
1210

Lambda comes from the Lambda Calculus and refers to anonymous functions in programming.

Why is this cool? It allows you to write quick throw away functions without naming them. It also provides a nice way to write closures. With that power you can do things like this.

Python

def adder(x):
    return lambda y: x + y
add5 = adder(5)
add5(1)
6

As you can see from the snippet of Python, the function adder takes in an argument x, and returns an anonymous function, or lambda, that takes another argument y. That anonymous function allows you to create functions from functions. This is a simple example, but it should convey the power lambdas and closures have.

Examples in other languages

Perl 5

sub adder {
    my ($x) = @_;
    return sub {
        my (x + $y
    }
}

my $add5 = adder(5);
print &$add5(1) == 6 ? "ok\n" : "not ok\n";

JavaScript

var adder = function (x) {
    return function (y) {
        return x + y;
    };
};
add5 = adder(5);
add5(1) == 6

JavaScript (ES6)

const adder = x => y => x + y;
add5 = adder(5);
add5(1) == 6

Scheme

(define adder
    (lambda (x)
        (lambda (y)
           (+ x y))))
(define add5
    (adder 5))
(add5 1)
6

C# 3.5 or higher

Func<int, Func<int, int>> adder = 
    (int x) => (int y) => x + y; // `int` declarations optional
Func<int, int> add5 = adder(5);
var add6 = adder(6); // Using implicit typing
Debug.Assert(add5(1) == 6);
Debug.Assert(add6(-1) == 5);

// Closure example
int yEnclosed = 1;
Func<int, int> addWithClosure = 
    (x) => x + yEnclosed;
Debug.Assert(addWithClosure(2) == 3);

Swift

func adder(x: Int) -> (Int) -> Int{
   return { y in x + y }
}
let add5 = adder(5)
add5(1)
6

PHP

b = 2;

$lambda = fn () => b;

echo $lambda();

Haskell

(\x y -> x + y) 

Java see this post

// The following is an example of Predicate : 
// a functional interface that takes an argument 
// and returns a boolean primitive type.

Predicate<Integer> pred = x -> x % 2 == 0; // Tests if the parameter is even.
boolean result = pred.test(4); // true

Lua

adder = function(x)
    return function(y)
        return x + y
    end
end
add5 = adder(5)
add5(1) == 6        -- true

Kotlin

val pred = { x: Int -> x % 2 == 0 }
val result = pred(4) // true

Ruby

Ruby is slightly different in that you cannot call a lambda using the exact same syntax as calling a function, but it still has lambdas.

def adder(x)
  lambda { |y| x + y }
end
add5 = adder(5)
add5[1] == 6

Ruby being Ruby, there is a shorthand for lambdas, so you can define adder this way:

def adder(x)
  -> y { x + y }
end

R

adder <- function(x) {
  function(y) x + y
}
add5 <- adder(5)
add5(1)
#> [1] 6
2 of 16
117

A lambda is a type of function, defined inline. Along with a lambda you also usually have some kind of variable type that can hold a reference to a function, lambda or otherwise.

For instance, here's a C# piece of code that doesn't use a lambda:

public Int32 Add(Int32 a, Int32 b)
{
    return a + b;
}

public Int32 Sub(Int32 a, Int32 b)
{
    return a - b;
}

public delegate Int32 Op(Int32 a, Int32 b);

public void Calculator(Int32 a, Int32 b, Op op)
{
    Console.WriteLine("Calculator: op(" + a + ", " + b + ") = " + op(a, b));
}

public void Test()
{
    Calculator(10, 23, Add);
    Calculator(10, 23, Sub);
}

This calls Calculator, passing along not just two numbers, but which method to call inside Calculator to obtain the results of the calculation.

In C# 2.0 we got anonymous methods, which shortens the above code to:

public delegate Int32 Op(Int32 a, Int32 b);

public void Calculator(Int32 a, Int32 b, Op op)
{
    Console.WriteLine("Calculator: op(" + a + ", " + b + ") = " + op(a, b));
}

public void Test()
{
    Calculator(10, 23, delegate(Int32 a, Int32 b)
    {
        return a + b;
    });
    Calculator(10, 23, delegate(Int32 a, Int32 b)
    {
        return a - b;
    });
}

And then in C# 3.0 we got lambdas which makes the code even shorter:

public delegate Int32 Op(Int32 a, Int32 b);

public void Calculator(Int32 a, Int32 b, Op op)
{
    Console.WriteLine("Calculator: op(" + a + ", " + b + ") = " + op(a, b));
}

public void Test()
{
    Calculator(10, 23, (a, b) => a + b);
    Calculator(10, 23, (a, b) => a - b);
}
🌐
Real Python
realpython.com › python-lambda
How to Use Python Lambda Functions – Real Python
December 1, 2023 - Alonzo Church formalized lambda calculus, a language based on pure abstraction, in the 1930s. Lambda functions are also referred to as lambda abstractions, a direct reference to the abstraction model of Alonzo Church’s original creation.
🌐
Google Support
support.google.com › docs › answer › 12508718
LAMBDA function - Google Docs Editors Help
Lambda helper functions (LHFs) are native functions which accept a reusable LAMBDA as an argument along with an input array(s). They help in advanced array-operations by executing the formula specified inside the LAMBDA, on each value in the input array. The reusable LAMBDA can be passed either ...
🌐
Pentera
pentera.io › home › lambda functions
What Is an AWS Lambda Function?
June 3, 2024 - AWS Lambda functions are serverless compute services that run code in response to events without managing infrastructure.
🌐
Cppreference
en.cppreference.com › w › cpp › language › lambda.html
Lambda expressions (since C++11) - cppreference.com
March 2, 2025 - Constructs a closure (an unnamed function object capable of capturing variables in scope). ... A variable __func__ is implicitly defined at the beginning of body, with semantics as described here. The lambda expression is a prvalue expression of unique unnamed non-union non-aggregate class ...
🌐
DataCamp
datacamp.com › tutorial › python-lambda-functions
Python Lambda Functions: A Beginner’s Guide | DataCamp
January 31, 2025 - Lambda functions in Python are powerful, concise tools for creating small, anonymous functions on the fly. They are perfect for simplifying short-term tasks, streamlining code with higher-order functions like map, filter, or sorted, and reducing clutter when defining temporary or throwaway logic.
🌐
Programiz
programiz.com › python-programming › anonymous-function
Python Lambda/ Function (With Examples)
In Python, a lambda function is a special type of function without the function name.
🌐
Wolfram MathWorld
mathworld.wolfram.com › LambdaFunction.html
Lambda Function -- from Wolfram MathWorld
October 6, 2008 - There are a number of functions in mathematics commonly denoted with a Greek letter lambda. Examples of one-variable functions denoted lambda(n) with a lower case lambda include the Carmichael functions, Dirichlet lambda function, elliptic lambda function, and Liouville function.
🌐
Dataquest
dataquest.io › blog › tutorial-lambda-functions-in-python
Tutorial: Lambda Functions in Python
March 6, 2023 - It's a simpler version of the following normal function with the def and return keywords: ... For now, however, our lambda function lambda x: x + 1 only creates a function object and doesn't return anything. We expected this: we didn't provide any value (an argument) to its parameter x.
🌐
Reddit
reddit.com › r/learnpython › lambda function
r/learnpython on Reddit: Lambda function
April 1, 2024 -

I understand what the lambda function is, its an anonymous function in one line, however why using it, and what really is it? I mean every code I looked at, has it and don't forget map() reduce and filter() function are used with it, what are all these used for and why, I did my research but I still don't understand, (I have a baby's brain 🧠 y'all)

🌐
The Python Coding Stack
thepythoncodingstack.com › p › whats-all-the-fuss-about-python-lambda-functions
What's All the Fuss About `lambda` Functions in Python
December 1, 2023 - And that's all there is, really. Python's lambda functions are just functions with no name. You can define them with one or more parameters (or none). However, you can only have a single expression that evaluates to a value.