This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Function (&)

or body& is a pure function. The formal parameters are # (or #1), #2, etc.
Function[x, body]
is a pure function with a single formal parameter x.
Function[{x1, x2, ...}, body]
is a pure function with a list of formal parameters.
  • When Function[body] or body& is applied to a set of arguments, # (or #1) is replaced by the first argument, #2 by the second, and so on. #0 is replaced by the function itself.
  • If there are more arguments supplied than #i in the function, the remaining arguments are ignored.  »
  • ## stands for the sequence of all arguments supplied.  »
  • ##n stands for arguments from number n on.  »
  • Function is analogous to in LISP or formal logic.
  • Function has attribute HoldAll. The function body is evaluated only after the formal parameters have been replaced by arguments.
  • The named formal parameters xi in Function[{x1, ...}, body] are treated as local, and are renamed xi$ when necessary to avoid confusion with actual arguments supplied to the function.  »
  • Function constructs can be nested in any way. Each is treated as a scoping construct, with named inner variables being renamed if necessary.  »
  • Function[params, body, {attr1, attr2, ...}] represents a pure function that is to be treated as having attributes attri for the purpose of evaluation.  »
New in 1