|
|
|||
|
|
| Mathematica Tutorial | Functions »|Tutorials » |
|
This gives Times[a, b, c] which yields the product of the elements in the list.
|
Here is a definition of a function that works like the built-in function GeometricMean, written using Apply.
|
| Apply[f,{a,b,...}] | apply f to a list, giving f[a, b, ...] |
| Apply[f,expr] or f@@expr | apply f to the top level of an expression |
| Apply[f,expr,{1}] or f@@@expr | apply f at the first level in an expression |
| Apply[f,expr,lev] | apply f at the specified levels in an expression |
Applying functions to lists and other expressions.
What Apply does in general is to replace the head of an expression with the function you specify. Here it replaces Plus by List.
|
|
|
|
|