Lambda (programming)
Appearance
Lambda' is an operator used to denote anonymous functions or closures, following the usage of lambda calculus, in programming languages such as C#, Lisp, Python, and Ruby.
Examples
C#
In C#, lambda expressions are often used with LINQ:
var allWikipediaPages = GetAllWikipediaPages();
var lambdaWikipediaPage = allWikipediaPages.First(wp => wp.Title == "Lambda (programming)");
Haskell
In Haskell, lambda expressions can take this form:
Prelude> let f = \x -> x + 1
Prelude> :t f
f :: Integer -> Integer
Prelude> f 2
3
Python
In Python, an example of this use of lambda is this sample of computer code that sorts a list alphabetically by the last character of each entry:
>>> stuff = ['woman', 'man', 'horse', 'boat', 'plane', 'dog']
>>> sorted(stuff, key=lambda word: word[-1])
['horse', 'plane', 'dog', 'woman', 'man', 'boat']