assign - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Assignment : assign

assign

perform assignments

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

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 aB 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.

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.

• 

For more information on thread safety, see index/threadsafe.

Examples

assigna,c

assigna=d,b=2

a,b,c

d,2,d

(1)

Since a and b have already been assigned, unevaluation quotes must be used.

assign'a','b'=3,4

a,b,c

3,4,d

(2)

assignT1,x,y,z

T1

x,y,z

(3)

ssolvex+y=1,2x+y=3,x,y

s:=x=2,y=1

(4)

assigns

x,y

2,1

(5)

Examples of typed assignments

kerneloptsassertlevel=2:

F := proc(x) local a; assign(a::integer, x); return a; end proc:

F3.4

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:

F3.4

Error, (in F) assertion failed in assignment, expected integer, got 3.4

assignK::float,hello

Error, (in assign) assertion failed in assignment, expected float, got hello

assignK::string,hello:

K

hello

(6)

assign can be used to set the value of environment variables.

EnvExample := proc( d ) assign( 'Digits', d ); Digits end;

EnvExample:=procdassign'Digits',d;Digitsend proc

(7)

EnvExample20

20

(8)

EnvExample30

30

(9)

See Also

:=

::

kernelopts

type

unassign

uneval

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam