assign(A = B)
name or function
name or function, or sequence of them
expression or sequence of expressions
list, set, or sequence of equations
The assign(a, B) and assign(a = B) commands make the assignment a≔B 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 3.
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.
The assign command is thread safe as of Maple 15, provided that the name or function being assigned to is not shared between threads.
For more information on thread safety, see index/threadsafe.
Since a and b have already been assigned, unevaluation quotes must be used.
s ≔ solve⁡x+y=1,2⁢x+y=3,x,y
Examples of typed assignments
F := proc(x) local a; assign(a::integer, x); return a; end proc:
Error, (in F) assertion failed in assignment, expected integer, got 3.4
F := proc(x) local a::integer; assign(a, x); return a; end proc:
Error, (in assign) assertion failed in assignment, expected float, got hello
assign can be used to set the value of environment variables.
EnvExample := proc( d ) assign( 'Digits', d ); Digits end;
Download Help Document
What kind of issue would you like to report? (Optional)