{
  "id": "enwiki-001361916885",
  "slug": "function-application",
  "title": "Function application",
  "qid": "",
  "lead": "In mathematics, function application (or evaluation) is the act of taking a function and an input from its domain to obtain the corresponding value from its range. In this sense, function application can be thought of as the opposite of function abstraction. It is central to programming languages derived from lambda calculus, such as LISP and Scheme, and also in functional languages. It has a role in the study of the denotational semantics of computer programs, because it is a continuous function on complete partial orders. Function application is also a continuous function in homotopy theory, and, indeed underpins the entire theory: it allows a homotopy deformation to be viewed as a continuous path in the space of functions. Likewise, valid mutations (refactorings) of computer programs can be seen as those that are \"continuous\" in the Scott topology.",
  "body": "In mathematics, function application (or evaluation) is the act of taking a function and an input from its domain to obtain the corresponding value from its range. In this sense, function application can be thought of as the opposite of function abstraction. It is central to programming languages derived from lambda calculus, such as LISP and Scheme, and also in functional languages. It has a role in the study of the denotational semantics of computer programs, because it is a continuous function on complete partial orders. Function application is also a continuous function in homotopy theory, and, indeed underpins the entire theory: it allows a homotopy deformation to be viewed as a continuous path in the space of functions. Likewise, valid mutations (refactorings) of computer programs can be seen as those that are \"continuous\" in the Scott topology. ==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. f(x) 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: f\\; x The latter notation is especially useful in combination with the currying isomorphism. Given a function f : (X \\times Y) \\to Z , its application is represented as f(x, y) by the former notation and f\\;(x,y) (or f \\; \\langle x, y \\rangle with the argument \\langle x, y \\rangle \\in X \\times Y written with the less common angle brackets) by the latter. However, functions in curried form f : X \\to (Y \\to Z) can be represented by juxtaposing their arguments: f\\; x \\; y , rather than f(x)(y) . This relies on function application being left-associative. When mathematical notation is represented in a digital document, the invisible zero-width Unicode characters and can be used to distinguish concatenation meaning function application from concatenation meaning multiplication. ==As an operator== Function application can be defined as an operator, called apply or \\$ , by the following definition: f \\mathop{\\,\\$\\,} x = f(x) 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; f(g(h(j(x)))) can be rewritten as: f \\mathop{\\,\\$\\,} g \\mathop{\\,\\$\\,} h \\mathop{\\,\\$\\,} j \\mathop{\\,\\$\\,} x This can be equivalently expressed using function composition as: (f \\circ g \\circ h \\circ j)(x) or even: (f \\circ g \\circ h \\circ j \\circ x)() if one considers x to be a constant function returning x . One is usually not content to write \" (x,y) \\in f \" to specify that y , and usually wishes for the more common function notation \" f(x) = y \" . Function application, or more specifically, the notation \" f(x) \", is not present in the usual signature of set theory, but may be added to the theory as a binary function symbol \\bullet ( \\bullet ) if desired without any loss of expressiveness by defining: X(Y) = \\left\\{ \\begin{array}{lll} z & \\text{if } X \\text{ is a function, and } (Y,z) \\in X \\\\ \\varnothing & \\text{otherwise} \\\\ \\end{array} \\right. Or, more formally: X(Y) = z \\iff (\\exists D,R ( X \\in R^D \\and ((Y,z) \\in X))) \\or (\\forall D,R(X \\notin R^D \\or (Y,z) \\notin X) \\and z = \\varnothing), where R^D denotes set exponentiation: the set of all functions from D to R . In prose: X(Y) = z if there exists a domain D and range R such that X is a function from D to R and (Y,z) \\in X ; or (the negation of former) and z = \\varnothing. The choice of using the empty set \\varnothing when X(Y) is undefined is arbitrary to ensure that the notation defined for the entire domain of discourse. If \\Psi(X,Y,z) denotes the formula on the right side of the biconditional above, for any two sets, X,Y the formula \\Psi associates a unique object z : \\forall X,Y \\, \\exists! z \\, \\Psi(X,Y,z) . Therefore the language of set theory can use an extension by definition to include the function application operation \\bullet ( \\bullet ) conservatively. In Common Lisp apply is a function that applies a function to a list of arguments (note here that \"+\" is a variadic function that takes any number of arguments): (apply #'+ (list 1 2)) Similarly in Scheme: (apply + (list 1 2)) In C# and Java, variadic arguments are simply collected in an array. Caller can explicitly pass in an array in place of the variadic arguments. This can only be done for a variadic parameter. It is not possible to apply an array of arguments to non-variadic parameter without using reflection. An ambiguous case arises should the caller want to pass an array itself as one of the arguments rather than using the array as a list of arguments. In this case, the caller should cast the array to Object to prevent the compiler from using the apply interpretation. variadicFunc(arrayOfArgs); With version 8 lambda expressions were introduced. Functions are implemented as objects with a functional interface, an interface with only one non-static method. The standard interface Function consist of the method (plus some static utility functions): R apply(T para) In JavaScript, function objects have an apply method, the first argument is the value of the this keyword inside the function; the second is the list of arguments: func.apply(null, args); ES6 adds the spread operator func(...args) which may be used instead of apply . In Lua, apply can be written this way: function apply(f,...) return f(...) end In Perl, arrays, hashes and expressions are automatically \"flattened\" into a single list when evaluated in a list context, such as in the argument list of a function Equivalent subroutine calls: @args = (@some_args, @more_args); func(@args); func(@some_args, @more_args); In PHP, apply is called call_user_func_array : call_user_func_array('func_name', $args); In Python and Ruby, the same asterisk notation used in defining variadic functions is used for calling a function on a sequence and array respectively: func(*args) Python originally had an apply function, but this was deprecated in favour of the asterisk in 2.3 and removed in 3.0. In R, do.call constructs and executes a function call from a name or a function and a list of arguments to be passed to it: f(x1, x2) can also be performed via do.call(what = f, args = list(x1, x2)) In Smalltalk, block (function) objects have a valueWithArguments: method which takes an array of arguments: aBlock valueWithArguments: args Since Tcl 8.5, a function can be applied to arguments with the apply command apply func ?arg1 arg2 ...? where the function is a two element list {args body} or a three element list {args body namespace}. \\mbox {Apply}(f,y)=f(y) or, equivalently one has the commuting diagram \\mbox{Apply} \\circ \\left( \\mbox{curry}(g) \\times \\mbox{id}_Y \\right) = g More precisely, curry and apply are adjoint functors. The notation [A\\to B] for the space of functions from A to B occurs more commonly in computer science. In category theory, however, [A\\to B] is known as the exponential object, and is written as B^A . There are other common notational differences as well; for example Apply is often called Eval, even though in computer science, these are not the same thing, with eval distinguished from Apply, as being the evaluation of the quoted string form of a function with its arguments, rather than the application of a function to some arguments. Also, in category theory, curry is commonly denoted by \\lambda , so that \\lambda g is written for curry(g). This notation is in conflict with the use of \\lambda in lambda calculus, where lambda is used to denote bound variables. With all of these notational changes accounted for, the adjointness of Apply and curry is then expressed in the commuting diagram The articles on exponential object and Cartesian closed category provide a more precise discussion of the category-theoretic formulation of this idea. Thus the use of lambda here is not accidental; the internal language of Cartesian closed categories is simply typed lambda calculus. The most general possible setting for Apply are the closed monoidal categories, of which the cartesian closed categories are an example. In homological algebra, the adjointness of curry and apply is known as tensor-hom adjunction. ==Other instances== The Curry–Howard correspondence relates function application to the logical rule of modus ponens. ==References==",
  "categories": [
    "20477222",
    "23118434",
    "23603337",
    "24043274",
    "29176345",
    "29176435",
    "30181011",
    "47074602",
    "62214016",
    "72655480"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1361916885",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1782845889.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001361916885",
    "type": "webpage",
    "title": "Function application",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/function-application",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          11
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          11
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001361916885",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1361916885",
    "note": "Immutable snapshot enwiki-001361916885"
  }
}