Function application
In mathematics, function application is the act of applying a function to an argument from its domain so as to obtain the corresponding value from its range. In this sense, function application can be thought of as the opposite of function abstraction.
Representation
Function application is usually depicted by juxtaposing the variable representing the function with its argument encompassed in parentheses. For example, the following expression represents the application of the function ƒ to its argument x.
- [math]\displaystyle{ f(x) }[/math]
In some instances, a different notation is used where the parentheses aren't required, and function application can be expressed just by juxtaposition. For example, the following expression can be considered the same as the previous one:
- [math]\displaystyle{ f\; x }[/math]
The latter notation is especially useful in combination with the currying isomorphism. Given a function [math]\displaystyle{ f : (X \times Y) \to Z }[/math], its application is represented as [math]\displaystyle{ f(x, y) }[/math] by the former notation and [math]\displaystyle{ f\;(x,y) }[/math] (or [math]\displaystyle{ f \; \langle x, y \rangle }[/math] with the argument [math]\displaystyle{ \langle x, y \rangle \in X \times Y }[/math] written with the less common angle brackets) by the latter. However, functions in curried form [math]\displaystyle{ f : X \to (Y \to Z) }[/math] can be represented by juxtaposing their arguments: [math]\displaystyle{ f\; x \; y }[/math], rather than [math]\displaystyle{ f(x)(y) }[/math]. This relies on function application being left-associative.
As an operator
Function application can be trivially defined as an operator, called apply or [math]\displaystyle{ \$ }[/math], by the following definition:
- [math]\displaystyle{ f \mathop{\,\$\,} x = f(x) }[/math]
The operator may also be denoted by a backtick (`).
If the operator is understood to be of low precedence and right-associative, the application operator can be used to cut down on the number of parentheses needed in an expression. For example;
- [math]\displaystyle{ f(g(h(j(x)))) }[/math]
can be rewritten as:
- [math]\displaystyle{ f \mathop{\,\$\,} g \mathop{\,\$\,} h \mathop{\,\$\,} j \mathop{\,\$\,} x }[/math]
However, this is perhaps more clearly expressed by using function composition instead:
- [math]\displaystyle{ (f \circ g \circ h \circ j)(x) }[/math]
or even:
- [math]\displaystyle{ (f \circ g \circ h \circ j \circ x)() }[/math]
if one considers [math]\displaystyle{ x }[/math] to be a constant function returning [math]\displaystyle{ x }[/math].
Other instances
Function application in the lambda calculus is expressed by β-reduction.
The Curry–Howard correspondence relates function application to the logical rule of modus ponens.
See also
![]() | Original source: https://en.wikipedia.org/wiki/Function application.
Read more |