evalassign -- assignment with
evaluation of the left hand side
Introductionevalassign(x, value, i) evaluates
x with substitution depth i and assigns
value to the result of the evaluation.
Call(s)evalassign(x, value, i)
evalassign(x, value)
Parametersx |
- | an object that evaluates to a valid left hand side of an assignment |
value |
- | any MuPAD object |
i |
- | a nonnegative integer less than 2^31 |
Returnsvalue.
Related
Functions:=, _assign, assign, assignElements, delete, eval, LEVEL, level
Detailsevalassign(x, value, i) evaluates
value, as usual. Then it evaluates x with
substitution depth i, and finally it assigns the
evaluation of value to the evaluation of x.
The difference between evalassign and the assignment
operator := is that the
latter does not evaluate its left hand side at all.
value takes place with
substitution depth given by LEVEL. By default, it is
1 within a procedure.LEVEL and level for the notion of substitution
depth and for details about evaluation.evalassign(x, value),
evalassign(x, value, 0), x :=
value, and _assign(x,
value) are all equivalent.x must be a valid left
hand side for an assignment. See the help page of := for details.
Example
1evalassign can be used in situations such
as the following. Suppose that an identifier a has another identifier
b as its value, and that we want to assign something to
this value of a, not to a
itself:
>> delete a, b: a := b: evalassign(a, 100, 1): level(a, 1), a, b
b, 100, 100
This would not have worked with the assignment operator
:=, which does not evaluate
its left hand side:
>> delete a, b: a := b: a := 100: level(a, 1), a, b
100, 100, b
Example
2The second argument may also be a sequence:
>> a := b: evalassign(a, (3,5), 1): b
3, 5
Backgroundlevel
is used for the evaluation of x. Hence i may
exceed the value of LEVEL._assign apply: see there on further
details on indexed assignments, assignments to slots, and the protect mechanism.