|
Calling Sequence
|
|
assign(a, B)
assign(A = B)
assign(t)
|
|
Parameters
|
|
a
|
-
|
name or function
|
A
|
-
|
name or function, or sequence of them
|
B
|
-
|
expression or sequence of expressions
|
t
|
-
|
list, set, or sequence of equations
|
|
|
|
|
Description
|
|
•
|
The assign(a, B) and assign(a = B) commands make the assignment and return NULL.
|
•
|
The arguments are evaluated, so if a is already assigned to the name x, then the function assign(a = 3) assigns x the value .
|
•
|
The assign(A=B) command, where A and B are both expression sequences with the same number of objects, assigns corresponding objects in B to objects in A, and returns NULL.
|
•
|
If the argument is a list or set of equations, then assign is applied to each equation in the list or set.
|
•
|
You can apply this function to a set of equations returned by the solve function when you want to assign the solution values to the variables.
|
•
|
The setting of kernelopts(assertlevel=2) causes type assertions to be checked. Whenever an assignment is made to a local variable with such a type assertion, the type of the right-hand side is checked after evaluation, but before the assignment is done. If the type of the right-hand side does not match, an assertion failure exception is raised.
|
•
|
The assign function can be used to set environment variables in the scope of the function calling assign.
|
|
|
Thread Safety
|
|
•
|
The assign command is thread safe as of Maple 15, provided that the name or function being assigned to is not shared between threads.
|
|
|
Examples
|
|
Since a and b have already been assigned, unevaluation quotes must be used.
>
|
|
>
|
|
>
|
|
Examples of typed assignments
>
|
|
>
|
F := proc(x) local a; assign(a::integer, x); return a; end proc:
|
>
|
F := proc(x) local a::integer; assign(a, x); return a; end proc:
|
>
|
|
>
|
|
assign can be used to set the value of environment variables.
>
|
EnvExample := proc( d ) assign( 'Digits', d ); Digits end;
|
| (7) |
|
|
|