prog::find -- find operands of
expressions
Introductionprog::find(ex, opr) returns all ``paths''
to the operand opr in the expression ex.
Call(s)prog::find(ex, opr)
Parametersex |
- | any MuPAD expression of type DOM_EXPR |
opr |
- | any MuPAD object |
Returnsa list of numbers that determine the position of the given object inside of the given expression, or a sequence of lists, if the expression contains the object several times
Related
Functions
Detailsprog::find(ex, obj) returns the position
of the object obj in the expression ex as
list. The list represents a ``path'' to the given object. With this
list and the functions op
and subsop, the object
can directly be accessed.i1, ...,
in.
The meaning is that the object is the in-th operand of
the (in - 1)-st operand etc. of the i1-st
operand of the expression ex.
Stated differently, .op(ex, [i1, ..., in]) = opr
Example
1The identifier a is the first operand of
the expression:
>> prog::find(a + b + c, a)
[1]
The number 1 occurs several times:
>> prog::find(f(1, 1, 1), 1)
[1], [2], [3]
Example
2The identifier a is the first operand of
the second operand of the first operand of the expression:
>> prog::find(b*(a - 1) + b*(x - 1), a)
[1, 2, 1]
The result of prog::find can be used to
access the element with op
or replace it with subsop:
>> op(b*(a - 1) + b*(x - 1), [1, 2, 1]); subsop(b*(a - 1) + b*(x - 1), [1, 2, 1] = A)
a
b (A - 1) + b (x - 1)
Backgroundprog::find can be used to manipulate complex
MuPAD objects with subsop.