Up | Next | Prev | PrevTail | Tail |
The map
operator applies a uniform evaluation pattern to all members of a composite
structure: a matrix, a list, or the arguments of an operator expression. The evaluation
pattern can be a unary procedure, an operator, or an algebraic expression with one free
variable.
It is used with the syntax:
map(fnc:function,obj:object)
Here obj
is a list, a matrix or an operator expression. fnc
can be one of the
following:
obj
as its single argument;
obj
, with the element substituted for the free variable;
var => rep
where var
is a variable (a
kernel without a subscript) and rep
is an expression that contains var
. The
replacement expression rep
is evaluated for each element of obj
with the
element substituted for var
. The variable var
may be optionally preceded
by a tilde.The rule form for fnc
is needed when more than one free variable occurs.
Examples:
map(abs,{1,-2,a,-a}) -> {1,2,ABS(A),ABS(A)} map(int(~w,x), mat((x^2,x^5),(x^4,x^5))) -> [ 3 6 ] [ x x ] [---- ----] [ 3 6 ] [ ] [ 5 6 ] [ x x ] [---- ----] [ 5 6 ] map(~w*6, x^2/3 = y^3/2 -1) -> 2*X^2=3*(Y^3-2)
You can use map
in nested expressions. However, you cannot apply map
to a
non-composite object, e.g. an identifier or a number.
Up | Next | Prev | PrevTail | Front |