THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
 Mathematica HowTo
How to | Work with Pure Functions
The ability to define and use your own functions is part of what gives Mathematica such power. It is often inconvenient to have to explicitly name a function for every small operation that you wish to perform. Mathematica lets you declare functions inline (called pure functions) to get around this.
The most transparent way to define a pure function is with Function. The first argument is a list of arguments, and the second is a function. This function adds its two arguments together:
 Out[1]=
 Out[2]=
You do not need to give the function a name to use it:
 Out[3]=
A common shorthand notation uses an & to mark the end of the pure function, with argument positions specified by #1, #2, and so on:
 Out[4]=
 Out[5]=
The advantage of a pure function is that it does not require a separate definition or a name:
 Out[6]=
If the pure function only has one argument, you can use # instead of #1. This function squares its argument:
 Out[7]=

Pure functions become quite powerful when used together with Map.
This makes a list of complex numbers into a list of ordered pairs:
 Out[8]=
This turns the ordered pairs back into complex numbers:
 Out[9]=
You can use /@ as a shorthand for Map. Use a pure function to create a list of clickable buttons:
 Out[10]=
 使用条款  • 隐私政策  • 网站索引 选择语言