# Anonymous function

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Anonymous_function
> Markdown URL: https://mediated.wiki/source/Anonymous_function.md
> Source: https://en.wikipedia.org/wiki/Anonymous_function
> Source revision: 1339036988
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Function definition that is not bound to an identifier

In [computer programming](/source/Computer_programming), an **anonymous function** (**function literal**, **lambda function**, or **block**) is a [function](/source/Function_(computer_science)) definition that is not [bound](/source/Name_binding) to an [identifier](/source/Name_(computer_science)). Anonymous functions are often arguments being passed to [higher-order functions](/source/Higher-order_function) or used for constructing the result of a higher-order function that needs to return a function.[1] If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in [functional programming languages](/source/Functional_programming_language) and other languages with [first-class functions](/source/First-class_function), where they fulfil the same role for the [function type](/source/Function_type) as [literals](/source/Literal_(computer_programming)) do for other [data types](/source/Data_type).

Anonymous functions originate in the work of [Alonzo Church](/source/Alonzo_Church) in his invention of the [lambda calculus](/source/Lambda_calculus), in which all functions are anonymous, in 1936, before electronic computers.[2] In several programming languages, anonymous functions are introduced using the keyword *lambda*, and anonymous functions are often referred to as **lambdas** or **lambda abstractions**. Anonymous functions have been a feature of [programming languages](/source/Programming_language) since [Lisp](/source/Lisp_(programming_language)) in 1958, and a growing number of modern programming languages support anonymous functions.

## Names

The names "lambda abstraction", "lambda function", and "lambda expression" refer to the notation of function abstraction in lambda calculus, where the usual function *f*(*x*) = *M* would be written (λ*x*.*M*), and where M is an expression that uses x. Compare to the Python syntax of lambda x: M.

The name "arrow function" refers to the mathematical "[maps to](/source/Maplet)" symbol, *x* ↦ *M*. Compare to the JavaScript syntax of x => M.[3]

## Uses

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2018) (Learn how and when to remove this message)

Anonymous functions can encapsulate functionality that does not require naming and is intended for short-term or localized use. Some notable examples include [closures](/source/Closure_(computer_science)) and [currying](/source/Currying).

The use of anonymous functions is a matter of style. Using them is never the only way to solve a problem; each anonymous function could instead be defined as a named function and called by name. Anonymous functions often provide a briefer notation than defining named functions. In languages that do not permit the definition of named functions in local scopes, anonymous functions may provide encapsulation via localized scope, however the code in the body of such anonymous function may not be re-usable, or amenable to separate testing. Short/simple anonymous functions used in expressions may be easier to read and understand than separately defined named functions, though lacking a [descriptive name](/source/Naming_convention_(programming)) may reduce code readability.

In some programming languages, anonymous functions are commonly implemented for very specific purposes such as binding events to callbacks or instantiating the function for particular values, which may be more efficient in a [Dynamic programming language](/source/Dynamic_programming_language), more readable, and less error-prone than calling a named function.

The following examples are written in Python 3.

### Sorting

Many languages provide a [generic function](/source/Generic_function) that [sorts](/source/Sort_algorithm) a list (or array) of objects into an [order](/source/Total_order) determined by a comparison function which compares two objects to determine if they are equal or if one is greater or less than the other. Using an anonymous comparison function expression passed as an argument to a generic sort function is often more concise than creating a named comparison function.

Consider this Python code sorting a list of strings by length of the string:

a: list[str] = ["house", "car", "bike"]
a.sort(key = lambda x: len(x))
print(a)
# prints ['car', 'bike', 'house']

The anonymous function in this example is the lambda expression:

lambda x: len(x)

The anonymous function accepts one argument, x, and returns the length of its argument, which is then used by the sort() method as the criteria for sorting.

Basic syntax of a lambda function in Python is

lambda arg1, arg2, arg3, ...: <operation on the arguments returning a value>

The expression returned by the lambda function can be assigned to a variable and used in the code at multiple places.

from typing import Callable

add: Callable[[int], int] = lambda a: a + a
print(add(20))
# prints 40

Another example would be sorting items in a list by the name of their class (in Python, everything has a class):

a: list[int | str] = [10, "number", 11.2]
a.sort(key=lambda x: x.__class__.__name__)
print(a)
# prints [11.2, 10, 'number']

Note that 11.2 has class name "float", 10 has class name "int", and 'number' has class name "str". The sorted order is "float", "int", then "str".

### Closures

Main article: [Closure (computer programming)](/source/Closure_(computer_programming))

Closures are functions evaluated in an environment containing [bound variables](/source/Bound_variable). The following example binds the variable "threshold" within an anonymous function that compares input values to this threshold.

def comp(threshold: int) -> Callable[[int], bool]:
    return lambda x: x < threshold

This can be used as a sort of generator of comparison functions:

func_a: Callable[[int], bool] = comp(10)
func_b: Callable[[int], bool] = comp(20)

print(func_a(5), func_a(8), func_a(13), func_a(21))
# prints True True False False

print(func_b(5), func_b(8), func_b(13), func_b(21))
# prints True True True False

It would be impractical to create a function for every possible comparison function and may be too inconvenient to keep the threshold around for further use. Regardless of the reason why a closure is used, the anonymous function is the entity that contains the functionality that does the comparing.

### Currying

Main article: [currying](/source/Currying)

Currying transforms a function that takes multiple arguments into a sequence of functions each accepting a single argument. In this example, a function that performs [division](/source/Integer_division) by any integer is transformed into one that performs division by a set integer.

def divide(x: int, y: int) -> float:
    return x / y

def divisor(d: int) -> Callable[[int], float]:
    return lambda x: divide(x, d)

half: Callable[[int], float] = divisor(2)
third: Callable[[int], float] = divisor(3)

print(half(32), third(32))
# prints 16.0 10.666666666666666

print(half(40), third(40))
# prints 20.0 13.333333333333334

While the use of anonymous functions is perhaps not common with currying, it still can be used. In the above example, the function divisor generates functions with a specified divisor. The functions half and third curry the divide function with a fixed divisor.

The divisor function also forms a closure by binding the variable d.

### Higher-order functions

A [higher-order function](/source/Higher-order_function) is a function that takes a function as an argument or returns one as a result. This technique is frequently employed to tailor the behavior of a generically defined function, such as a loop or recursion pattern. Anonymous functions are a convenient way to specify such function arguments. The following examples are in Python 3.

#### Map

Main article: [Map (higher-order function)](/source/Map_(higher-order_function))

The map function performs a function call on each element of a list. The following example [squares](/source/Square_(algebra)) every element in an array with an anonymous function.

a: List[int] = [1, 2, 3, 4, 5, 6]
print(list(map(lambda x: x * x, a)))
# prints [1, 4, 9, 16, 25, 36]

The anonymous function takes an argument and returns its square. The above form is discouraged by the creators of the language, who maintain that the form presented below has the same meaning and is more aligned with the philosophy of the language:

a: List[int] = [1, 2, 3, 4, 5, 6]
print([x * x for x in a])
# prints [1, 4, 9, 16, 25, 36]

#### Filter

Main article: [Filter (higher-order function)](/source/Filter_(higher-order_function))

The filter function returns all elements from a list that evaluate True when passed to a certain function.

a: List[int] = [1, 2, 3, 4, 5, 6]
print(list(filter(lambda x: x % 2 == 0, a)))
# prints [2, 4, 6]

The anonymous function checks if the argument passed to it is even. The same as with map, the form below is considered more appropriate:

a: List[int] = [1, 2, 3, 4, 5, 6]
print([x for x in a if x % 2 == 0])
# prints [2, 4, 6]

#### Fold

Main article: [Fold (higher-order function)](/source/Fold_(higher-order_function))

A fold function runs over all elements in a structure (for lists usually left-to-right, a "left fold", called reduce in Python), accumulating a value as it goes. This can be used to combine all elements of a structure into one value, for example:

a: List[int] = [1, 2, 3, 4, 5]
print(functools.reduce(lambda x, y: x * y, a))
# prints 120

This performs

- ( ( ( 1 × 2 ) × 3 ) × 4 ) × 5 = 120. {\displaystyle \left(\left(\left(1\times 2\right)\times 3\right)\times 4\right)\times 5=120.}

The anonymous function here is the multiplication of the two arguments.

A fold does not necessarily produce a single scalar value; it can also generate structured results such as lists. Instead, both map and filter can be created using fold. In map, the value that is accumulated is a new list, containing the results of applying a function to each element of the original list. In filter, the value that is accumulated is a new list containing only those elements that match the given condition.

## List of languages

The following is a list of [programming languages](/source/Programming_language) that support unnamed anonymous functions fully, or partly as some variant, or not at all.

The following table illustrates several common patterns. Notably, languages like [C](/source/C_(programming_language)), [Pascal](/source/Pascal_(programming_language)), and [Object Pascal](/source/Object_Pascal)—which traditionally do not support anonymous functions—are all [statically typed](/source/Statically_typed) languages. However, statically typed languages can support anonymous functions. For example, the [ML](/source/ML_(programming_language)) languages are statically typed and fundamentally include anonymous functions, and [Delphi](/source/Delphi_(programming_language)), a dialect of [Object Pascal](/source/Object_Pascal), has been extended to support anonymous functions, as has [C++](/source/C%2B%2B) (by the [C++11](/source/C%2B%2B11) standard). Second, the languages that treat functions as [first-class functions](/source/First-class_function) ([Dylan](/source/Dylan_(programming_language)), [Haskell](/source/Haskell_(programming_language)), [JavaScript](/source/JavaScript), [Lisp](/source/Lisp_(programming_language)), [ML](/source/ML_(programming_language)), [Perl](/source/Perl), [Python](/source/Python_(programming_language)), [Ruby](/source/Ruby_(programming_language)), [Scheme](/source/Scheme_(programming_language))) generally have anonymous function support so that functions can be defined and passed around as easily as other data types.

This list is incomplete; you can help by adding missing items. (August 2008)

List of languages Language Support Notes ActionScript Y Ada Y Expression functions are a part of Ada2012, access-to-subprogram[4] ALGOL 68 Y APL Y Dyalog, ngn and dzaima APL fully support both dfns and tacit functions. GNU APL has rather limited support for dfns. Assembly languages N AHK Y Since AutoHotkey V2, anonymous functions are supported with a syntax similar to JavaScript. Bash Y A library has been made to support anonymous functions in Bash.[5] C N Support is provided in Clang and along with the LLVM compiler-rt lib. GCC support is given for a macro implementation which enables the possibility of use. See below for more details. C# Y [6] C++ Y As of the C++11 standard CFML Y As of Railo 4,[7] ColdFusion 10[8] Clojure Y [9] COBOL N Micro Focus's non-standard Managed COBOL dialect supports lambdas, which are called anonymous delegates/methods.[10] Curl Y D Y [11] Dart Y [12] Delphi Y [13] Dylan Y [14] Eiffel Y Elm Y [15] Elixir Y [16] Erlang Y [17] F# Y [18] Excel Y Excel worksheet function, 2021 beta release[19] Factor Y "Quotations" support this[20] Fortran N Frink Y [21] Go Y [22] Gosu Y [23] Groovy Y [24] Haskell Y [25] Haxe Y [26] Java Y Supported since Java 8. JavaScript Y [27] Julia Y [28] Kotlin Y [29] Lisp Y Logtalk Y Lua Y [30] MUMPS N Maple Y [31] MATLAB Y [32] Maxima Y [33] Nim Y [34] OCaml Y [35] Octave Y [36] Object Pascal Y Delphi, a dialect of Object Pascal, supports anonymous functions (formally, anonymous methods) natively since Delphi 2009. The Oxygene Object Pascal dialect also supports them. Objective-C (Mac OS X 10.6+) Y Called blocks; in addition to Objective-C, blocks can also be used on C and C++ when programming on Apple's platform. OpenSCAD Y Function Literal support was introduced with version 2021.01.[37] Pascal N Perl Y [38] PHP Y As of PHP 5.3.0, true anonymous functions are supported.[39] Formerly, only partial anonymous functions were supported, which worked much like C#'s implementation. PL/I N Python Y Python supports anonymous functions through the lambda syntax,[40] which supports only expressions, not statements. R Y Racket Y [41] Raku Y [42] Rexx N RPG N Ruby Y Ruby's anonymous functions, inherited from Smalltalk, are called blocks.[43] Rust Y [44] Scala Y [45] Scheme Y Smalltalk Y Smalltalk's anonymous functions are called blocks. Standard ML Y [46] Swift Y Swift's anonymous functions are called Closures.[47] TypeScript Y [48] Typst Y [49] Tcl Y [50] Vala Y [50] Visual Basic .NET v9 Y [51] Visual Prolog v 7.2 Y [52] Wolfram Language Y [53] Zig N [54]

## Examples of anonymous functions

Main article: [Examples of anonymous functions](/source/Examples_of_anonymous_functions)

## See also

- [Computer programming portal](https://en.wikipedia.org/wiki/Portal:Computer_programming)

- [First-class function](/source/First-class_function)

- [Lambda calculus definition](/source/Lambda_calculus_definition)

## References

1. **[^](#cite_ref-1)** ["Higher order functions"](http://learnyouahaskell.com/higher-order-functions). learnyouahaskell.com. Retrieved 3 December 2014.

1. **[^](#cite_ref-2)** Fernandez, Maribel (2009), [*Models of Computation: An Introduction to Computability Theory*](https://books.google.com/books?id=FPFsnzzebhQC&pg=PA33), Undergraduate Topics in Computer Science, Springer Science & Business Media, p. 33, [ISBN](/source/ISBN_(identifier)) [9781848824348](https://en.wikipedia.org/wiki/Special:BookSources/9781848824348), The Lambda calculus ... was introduced by Alonzo Church in the 1930s as a precise notation for a theory of anonymous functions

1. **[^](#cite_ref-3)** ["Arrow function expressions - JavaScript"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). *MDN*. Retrieved August 21, 2019.

1. **[^](#cite_ref-4)** ["Access Types"](https://www.adaic.org/resources/add_content/standards/05rm/html/RM-3-10.html#S0082). *www.adaic.org*. Retrieved 2024-06-27.

1. **[^](#cite_ref-5)** ["Bash lambda"](https://github.com/spencertipping/bash-lambda). *[GitHub](/source/GitHub)*. 2019-03-08.

1. **[^](#cite_ref-6)** BillWagner. ["Lambda expressions - C# reference"](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions). *docs.microsoft.com*. Retrieved 2020-11-24.

1. **[^](#cite_ref-7)** ["Closure support"](https://web.archive.org/web/20140106031957/http://www.getrailo.org/index.cfm/whats-up/railo-40-beta-released/features/closures/). Archived from the original on 2014-01-06. Retrieved 2014-01-05.

1. **[^](#cite_ref-8)** ["Whats new in ColdFusion 10"](https://web.archive.org/web/20140106032853/https://learn.adobe.com/wiki/display/coldfusionen/Whats+new+in+ColdFusion+10). Archived from [the original](https://learn.adobe.com/wiki/display/coldfusionen/Whats+new+in+ColdFusion+10) on 2014-01-06. Retrieved 2014-01-05.

1. **[^](#cite_ref-9)** ["Clojure - Higher Order Functions"](https://clojure.org/guides/higher_order_functions). *clojure.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-10)** ["Managed COBOL Reference"](http://documentation.microfocus.com/help/topic/com.microfocus.eclipse.infocenter.visualcobol.vs/GUID-DA75663F-6357-4064-8112-C87E7457DE51.html). *Micro Focus Documentation*. [Micro Focus](/source/Micro_Focus). Retrieved 25 February 2014.{{[cite web](https://en.wikipedia.org/wiki/Template:Cite_web)}}: CS1 maint: deprecated archival service ([link](https://en.wikipedia.org/wiki/Category:CS1_maint:_deprecated_archival_service))

1. **[^](#cite_ref-11)** ["Functions - D Programming Language"](https://dlang.org/spec/function.html). *dlang.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-:0_12-0)** ["A tour of the Dart language"](https://dart.dev/guides/language/language-tour). *dart.dev*. Retrieved 2020-11-24.

1. **[^](#cite_ref-13)** ["Anonymous Methods in Delphi - RAD Studio"](http://docwiki.embarcadero.com/RADStudio/Sydney/en/Anonymous_Methods_in_Delphi#:~:text=As%20the%20name%20suggests,%20an,a%20parameter%20to%20a%20method.). *docwiki.embarcadero.com*. Retrieved 2020-11-24.

1. **[^](#cite_ref-14)** ["Functions — Dylan Programming"](https://opendylan.org/books/dpg/func.html). *opendylan.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-15)** ["docs/syntax"](https://elm-lang.org/docs/syntax). *elm-lang.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-:1_16-0)** ["Erlang/Elixir Syntax: A Crash Course"](https://elixir-lang.org/crash-course.html). *elixir-lang.github.com*. Retrieved 2020-11-24.

1. **[^](#cite_ref-:2_17-0)** ["Erlang -- Funs"](https://erlang.org/doc/programming_examples/funs.html). *erlang.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-:3_18-0)** cartermp. ["Lambda Expressions: The fun Keyword - F#"](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword). *docs.microsoft.com*. Retrieved 2020-11-24.

1. **[^](#cite_ref-Microsoft_Excel_Blog_2021-01-25_19-0)** ["LAMBDA: The ultimate Excel worksheet function"](https://www.microsoft.com/en-us/research/blog/lambda-the-ultimatae-excel-worksheet-function/). *microsoft.com*. 25 January 2021. Retrieved 2021-03-30.

1. **[^](#cite_ref-20)** ["Quotations - Factor Documentation"](http://docs.factorcode.org/content/article-quotations.html). Retrieved 26 December 2015. A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called using the Fundamental combinators.

1. **[^](#cite_ref-21)** ["Frink"](https://frinklang.org/). *frinklang.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-:4_22-0)** ["Anonymous Functions in GoLang"](https://golangdocs.com/anonymous-functions-in-golang). *GoLang Docs*. 9 January 2020. Retrieved 2020-11-24.

1. **[^](#cite_ref-23)** ["Gosu Documentation"](http://gosu-lang.org/doc/pdf/gosuref.pdf) (PDF). Retrieved 4 March 2013.

1. **[^](#cite_ref-24)** ["Groovy Documentation"](https://web.archive.org/web/20120522213410/http://groovy.codehaus.org/Closures). Archived from [the original](http://groovy.codehaus.org/Closures) on 22 May 2012. Retrieved 29 May 2012.

1. **[^](#cite_ref-25)** ["Anonymous function - HaskellWiki"](https://wiki.haskell.org/Anonymous_function). *wiki.haskell.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-26)** ["Lambda"](https://haxe.org/manual/std-Lambda.html). *Haxe - The Cross-platform Toolkit*. Retrieved 2022-01-14.

1. **[^](#cite_ref-27)** ["Functions - JavaScript | MDN"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions). *developer.mozilla.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-28)** ["Functions · The Julia Language"](https://docs.julialang.org/en/v1/manual/functions/). *docs.julialang.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-29)** ["Higher-Order Functions and Lambdas - Kotlin Programming Language"](https://kotlinlang.org/docs/reference/lambdas.html). *Kotlin*. Retrieved 2020-11-24.

1. **[^](#cite_ref-30)** ["Programming in Lua : 6"](https://www.lua.org/pil/6.html). *www.lua.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-31)** ["Maple Programming: 1.6: Anonymous functions and expressions - Application Center"](https://www.maplesoft.com/applications/view.aspx?sid=1522&view=html). *www.maplesoft.com*. Retrieved 2020-11-24.

1. **[^](#cite_ref-32)** ["Anonymous Functions - MATLAB & Simulink"](https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html). *www.mathworks.com*. Retrieved 2022-01-14.

1. **[^](#cite_ref-33)** ["Maxima 5.17.1 Manual: 39. Function Definition"](http://maths.cnam.fr/Membres/wilk/MathMax/help/Maxima/maxima_39.html#:~:text=Maxima%20simplifies%20funmake%20%27s%20return%20value.&text=Defines%20and%20returns%20a%20lambda,of%20the%20function%20is%20expr_n%20.). *maths.cnam.fr*. Retrieved 2020-11-24.

1. **[^](#cite_ref-auto1_34-0)** ["Nim Manual"](https://nim-lang.github.io/Nim/manual.html#procedures-anonymous-procs). *nim-lang.github.io*.

1. **[^](#cite_ref-35)** ["Code Examples – OCaml"](https://ocaml.org/learn/taste.html). *ocaml.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-36)** ["GNU Octave: Anonymous Functions"](https://octave.org/doc/v4.0.1/Anonymous-Functions.html). *octave.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-37)** ["Function Literals"](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules#Function_Literals). *OpenSCAD User Manual*. Wikibooks. Retrieved 22 February 2021.

1. **[^](#cite_ref-:5_38-0)** ["perlsub - Perl subroutines - Perldoc Browser"](https://perldoc.perl.org/perlsub). *perldoc.perl.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-39)** ["PHP: Anonymous functions - Manual"](https://www.php.net/manual/en/functions.anonymous.php). *www.php.net*. Retrieved 2020-11-24.

1. **[^](#cite_ref-:6_40-0)** ["6. Expressions — Python 3.9.0 documentation"](https://docs.python.org/3/reference/expressions.html). *docs.python.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-41)** ["4.4 Functions: lambda"](https://docs.racket-lang.org/guide/lambda.html). *docs.racket-lang.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-42)** ["Functions"](https://docs.raku.org/language/functions). *docs.raku.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-:10_43-0)** Sosinski, Robert (2008-12-21). ["Understanding Ruby Blocks, Procs and Lambdas"](https://web.archive.org/web/20140531123646/http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/). Reactive.IO. Archived from [the original](http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/) on 2014-05-31. Retrieved 2014-05-30.

1. **[^](#cite_ref-44)** ["Closures: Anonymous Functions that Can Capture Their Environment - The Rust Programming Language"](https://doc.rust-lang.org/book/ch13-01-closures.html). *doc.rust-lang.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-45)** ["Anonymous Functions"](https://docs.scala-lang.org/overviews/scala-book/anonymous-functions.html). *Scala Documentation*. Retrieved 2022-01-14.

1. **[^](#cite_ref-46)** ["Recitation 3: Higher order functions"](https://www.cs.cornell.edu/courses/cs312/2008sp/recitations/rec03.html). *www.cs.cornell.edu*. Retrieved 2022-01-14.

1. **[^](#cite_ref-:9_47-0)** ["Closures — The Swift Programming Language (Swift 5.5)"](https://docs.swift.org/swift-book/LanguageGuide/Closures.html). *docs.swift.org*.

1. **[^](#cite_ref-48)** ["Documentation - Everyday Types"](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html). *www.typescriptlang.org*. Retrieved 2022-01-14.

1. **[^](#cite_ref-49)** ["Function Type - Typst Documentation"](https://typst.app/docs/reference/foundations/function/#unnamed). *typst.app*. Retrieved 2024-09-10.

1. ^ [***a***](#cite_ref-:7_50-0) [***b***](#cite_ref-:7_50-1) ["Projects/Vala/Tutorial - GNOME Wiki!"](https://wiki.gnome.org/Projects/Vala/Tutorial). *wiki.gnome.org*. Retrieved 2020-11-24.

1. **[^](#cite_ref-51)** KathleenDollard (15 September 2021). ["Lambda Expressions - Visual Basic"](https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions). *docs.microsoft.com*. Retrieved 2022-01-14.

1. **[^](#cite_ref-52)** ["Language Reference/Terms/Anonymous Predicates - wiki.visual-prolog.com"](https://wiki.visual-prolog.com/index.php?title=Language_Reference/Terms/Anonymous_Predicates). *wiki.visual-prolog.com*. Retrieved 2022-01-14.

1. **[^](#cite_ref-:8_53-0)** ["Pure Anonymous Function: Elementary Introduction to the Wolfram Language"](https://www.wolfram.com/language/elementary-introduction/2nd-ed/26-pure-anonymous-functions.html.en). *www.wolfram.com*. Retrieved 2022-01-14.

1. **[^](#cite_ref-54)** ["Lambdas, Closures and everything in between · Issue #1048 · ziglang/zig"](https://github.com/ziglang/zig/issues/1048). *GitHub*. Retrieved 2023-08-21.

## External links

- [Anonymous Methods - When Should They Be Used?](http://www.deltics.co.nz/blog/?p=48) (blog about anonymous function in Delphi)

- [Compiling Lambda Expressions: Scala vs. Java 8](http://www.takipiblog.com/2014/01/16/compiling-lambda-expressions-scala-vs-java-8/)

- [php anonymous functions](https://web.archive.org/web/20160308090330/http://webwidetutor.com/php/php-anonymous-functions-?id=12) php anonymous functions

- [Lambda functions in various programming languages](http://dobegin.com/lambda-functions-everywhere/)

- [Functions in Go](https://web.archive.org/web/20230314153037/https://learngolangonline.com/functions)

v t e Programming paradigms Imperative Structured Jackson structures Block-structured Modular Non-structured Procedural Programming in the large and in the small Design by contract Invariant-based Nested function Object-oriented Class-based, Prototype-based, Object-based Agent Immutable object Persistent Uniform function call syntax Declarative Functional Recursive Anonymous function (Partial application) Higher-order Purely functional Total Strict GADTs Dependent types Functional logic Point-free style Expression-oriented Applicative, Concatenative Function-level, Value-level Monad Dataflow Flow-based Reactive (Functional reactive) Signals Streams Synchronous Logic Abductive logic Answer set Constraint (Constraint logic) Inductive logic Nondeterministic Ontology Probabilistic logic Query Domain- specific language (DSL) Algebraic modeling Array Automata-based (Action) Command (Spacecraft) Differentiable End-user Grammar-oriented Interface description Language-oriented List comprehension Low-code Modeling Natural language Non-English-based Page description Pipes and filters Probabilistic Quantum Scientific Scripting Set-theoretic Simulation Stack-based System Tactile Templating Transformation (Graph rewriting, Production, Pattern) Visual Concurrent, parallel Actor-based Automatic mutual exclusion Choreographic programming Concurrent logic (Concurrent constraint logic) Concurrent OO Macroprogramming Multitier programming Organic computing Parallel programming models Partitioned global address space Process-oriented Relativistic programming Service-oriented Structured concurrency Metaprogramming Attribute-oriented Automatic (Inductive) Dynamic Extensible Generic Homoiconicity Interactive Macro (Hygienic) Metalinguistic abstraction Multi-stage Program synthesis (Bayesian, by demonstration, by example, vibe coding) Reflective Self-modifying code Symbolic Template Separation of concerns Aspects Components Data-driven Data-oriented Event-driven Features Literate Roles Subjects Comparisons/Lists Comparison (multi-paradigm, object-oriented, functional), List (OO, by type)

---
Adapted from the Wikipedia article [Anonymous function](https://en.wikipedia.org/wiki/Anonymous_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Anonymous_function?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
