Call a function
Position-based calling
Analytica uses the standard position-based syntax for using, or calling, a function. You simply list the actual parameters after the function name, within parentheses, and separated by commas, in the same sequence in which they are defined. For example:
Capm(5%, 8%, StockBeta)
This evaluates function Capm(Rf, Rm, Beta) with Rf set to 5%, Rm set to 8%, and Beta set to Stockbeta.
Name-based calling
Analytica also supports a more flexible name-based calling syntax, identifying the parameters by name:
Capm(beta: StockBeta, rf: 5%, rm: 8%)
In this case, we name each parameter, and put its actual value after a colon “:” after the parameter name. The name-value pairs are separated by commas. You can give the parameters in any order. They must include all required parameters. This method is much easier to read when the function has many parameters. It is especially useful when many parameters are optional (page 369).
You can mix positional and named parameters, provided the positional parameters come first:
Fu1(1, 2, D: 4, C:3)
You cannot give a positional parameter after a named parameter. For example, the following entry displays an error message:
Fu1(1, D: 4, 2, 3) Invalid
This name-based calling syntax is analogous to Analytica’s name-based subscripting for arrays to obtain selected elements of an array, in which you specify indexes by name. You don’t have to remember a particular sequence to write or understand an expression. See “x[i=v]: Subscript construct” on page 183.
Enable comment auto-refresher