Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  Built-in Functions /  Programming /  Functional Programming /

Function

FilledSmallSquare Function[body] or body& is a pure function. The formal parameters are # (or #1), #2, and so on.
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 Function is analogous to in LISP or formal logic.
FilledSmallSquare 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 See The Mathematica Book on the web: Section 2.2.5.
FilledSmallSquare See also: Apply.