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

Documentation / Mathematica / Built-in Functions / Programming / Functional Programming /

Function

FilledSmallSquare Function[body] or body& is a pure function. The formal parameters are # (or #1), #2, etc.

FilledSmallSquare Function[x, body] is a pure function with a single formal parameter x.

FilledSmallSquare Function[, , ... , body] is a pure function with a list of formal parameters.

FilledSmallSquare Example: (# + 1)&[x] LongRightArrow.

FilledSmallSquare Map[(# + 1)&, x, y, z] LongRightArrow.

FilledSmallSquare 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.

FilledSmallSquare If there are more arguments supplied than #i in the function, the remaining arguments are ignored.

FilledSmallSquare ## stands for the sequence of all arguments supplied.

FilledSmallSquare ##n stands for arguments from number n on.

FilledSmallSquare f[##, ##2]& [x, y, z] LongRightArrow.

FilledSmallSquare Function is analogous to in LISP or formal logic.

FilledSmallSquare Function has attribute HoldAll. The function body is evaluated only after the formal parameters have been replaced by arguments.

FilledSmallSquare 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.

FilledSmallSquare Function is treated as a scoping construct (see Section A.3.8).

FilledSmallSquare Function[params, body, , , ... ] represents a pure function that is to be treated as having attributes for the purpose of evaluation.

FilledSmallSquare See Section 2.2.5.

FilledSmallSquare See also: Apply, CompiledFunction.

FilledSmallSquare New in Version 1.

Further Examples