Computer ScienceProgrammingMedium

Lambda Function

Also known as:anonymous functionlambda expressionarrow function

A lambda function is an anonymous, inline function expression defined without a formal name, typically used for short, single-use operations. Derived from lambda calculus (λ-calculus), lambda functions can be passed as arguments, returned from other functions, and stored in variables, making them essential to functional programming paradigms. They are supported in Python (lambda keyword), Java (->), JavaScript (=>), Haskell, and most modern languages.

Lambda Function Syntax Across Languages

LanguageSyntax ExampleMax StatementsReturn Keyword Needed?
Pythonlambda x: x * 2Single expressionNo (implicit)
JavaScript(x) => x * 2Multiple (with braces)Only with braces
Javax -> x * 2Single expression / blockOnly in block form
C# (LINQ)x => x * 2Expression or blockOnly in block form
Haskell\x -> x * 2Single expressionNo (implicit)

Interactive Tools

Codecademy – Python Lambda

Open Tool

Brilliant – Lambda Calculus

Open Tool

Khan Academy – Intro to Functions

Open Tool
Lambda symbol used in lambda calculus and programming

Wikimedia Commons, CC BY-SA

Related Terms

From the Greek letter λ (lambda). Alonzo Church introduced λ-calculus in the 1930s to formalise mathematical functions. John McCarthy adopted the term for Lisp in 1958, embedding it permanently in programming language theory.

lambdaanonymous-functionfunctional-programminghigher-orderexpression