Function[body] 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[, , ... , body] is a pure function with a list of formal parameters.
Example: (# + 1)&[x] .
Map[(# + 1)&, x, y, z] .
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.
f[##, ##2]& [x, y, z] .
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 in Function[, ... , body] are treated as local, and are renamed $ when necessary to avoid confusion with actual arguments supplied to the function.
Function is treated as a scoping construct (see Section A.3.8).
Function[params, body, , , ... ] represents a pure function that is to be treated as having attributes for the purpose of evaluation.
See Section 2.2.5.
See also: Apply, CompiledFunction.
New in Version 1.