Apply
Apply[ func, expr ]
Apply[ func, expr ] replaces the leading function of expr with func. In case expr has no leading function, func is applied directly to expr.
| Example | in | out |
|---|---|---|
The function plus applied to the list {2,3}. |
Apply[ plus, {2,3} ] |
plus[2,3] |
The function times applied to the addition 2+3. |
Apply[ times, 2+3 ] |
times[2,3] |
The function List applied to the variable poly defined as 2x^2 + 3x + 6 in the script to obtain a list of its terms. |
Apply[List, poly ] |
{2x^2, 3x, 6} |
The function List applied to an expression without a function. |
Apply[List, 4] |
{4} |
| Applying a function to a term without a leading function after evaluation. | Apply[sqrt, CalcPlus[2,3] ] |
sqrt[5] |