|
5.2.1 apply
Syntax:
apply( expression , function );
Purpose:
- applies the function to all elements of the first argument.
The first argument must be of type
intvec ,
intmat ,
or list .
The result will be of the same type as the first argument.
The function must be a kernel command or a procedure which takes one
argument and returns a type which can be an element of the result.
Example:
| proc p(int x) {return(x^2);}
intvec v=1,2,3;
apply(v,p);
==> 1,4,9
|
|