Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Function

Usage

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.


Notes

• Example: (# + 1)&[x]LongRightArrow .
Map[(# + 1)&,  x, y, z ]LongRightArrow .
• 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]LongRightArrow .
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.


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: