lambda
C2Pronunciation
UK
- /lˈæmbdə/
US
- /ˈlæmdə/
Description
- Greek letter
- unnamed function in programming
- symbol for wavelength or decay rate
Lambda (λ) is a bit of a chameleon. First, it is the eleventh letter of the Greek alphabet. In math and physics, it often stands for things like wavelength or a decay rate. In programming, it usually means an anonymous function or lambda expression - a small piece of code you write without giving it a name. It is handy when you need a quick rule or calculation for one small job. You might see it in Python, Lisp, Haskell, Java, or JavaScript.
Think of it like this: if regular functions are named recipes, lambdas are like quick notes for a single dish - useful right then and there, without making a whole new recipe card.
Lambda is a fascinating word with roots stretching back to ancient Greece. It is the eleventh letter of the Greek alphabet (Λ, λ), and for a long time that was its main meaning. From there, it became a useful symbol in many technical fields. In physics, for example, it often stands for wavelength, and in some formulas it can stand for a decay constant or other specific values.
In mathematics and computer science, the word gained another important meaning through lambda calculus, a formal system for describing functions. Because of that history, many programming languages use the word lambda for an unnamed function written directly where it is needed. These small inline functions are helpful when you want a simple action without the extra step of defining a separate named function.
Think of it like needing to sort a list based on a specific criterion. Instead of writing a separate "sort_by_length" function, you can use a lambda expression directly within the sorting command: `my_list.sort(key=lambda x: len(x))`. This tells Python to sort the list by the length of each element (`len(x)`), all in one line!
Lambda functions are especially important in functional programming languages like Lisp and Haskell, where working with functions as values is central. They also appear in many other languages, including Python, Java, C#, and JavaScript, although the exact syntax is different from language to language.
The power of lambda lies in its conciseness and flexibility. It lets you create a function on demand, which can make code cleaner when the task is small and local. So whether it is naming a Greek letter, marking a value in a physics formula, or describing a short function in code, lambda is a versatile term that connects ancient language with modern science and computing.
Examples
- 1
Greek letter
In the diagram, lambda is written as λ next to the wave.
- 2
Physics equation
The equation uses lambda to represent the wavelength of the light.
- 3
Python function
In Python, I used a lambda to sort the list by each person's age.
Domain
In Python, a lambda is a small function written without giving it a name.
- 4
Code readability
The team rewrote the lambda as a regular function so the code was easier to read.
- 5
Cloud service
We moved the image-processing job to AWS Lambda so it runs only when someone uploads a file.
Domain
AWS Lambda
a cloud service that runs code when needed
Forms and spellings
2 forms open this card.
Main spelling
- lambdanoun
Forms
- lambdaspluralnoun