assigned - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


assigned

check if a name is assigned

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Compatibility

Calling Sequence

assigned(n)

assigned(n, val)

Parameters

n

-

name, subscripted name, or function call

val

-

name, assignable

Description

• 

The assigned function returns true if n has a value other than its own name, and returns false otherwise.

  

Note: The assigned function returns true if you have placed assumptions on n using the assume command.

• 

This function is one of the exceptions to the normal evaluation rule for arguments of a function. The argument to assigned will only be evaluated as a name (see the evaln function) rather than fully evaluated.

• 

The definition of assigned for array/table subscripts is

assigned⁡Ai=evalb⁡Ai≠evaln⁡Ai

• 

The definition of assigned for function calls is

assigned⁡f⁡x=evalb⁡f⁡x≠evaln⁡f⁡x

• 

If an optional second argument is provided, then that parameter is set to the assigned value of n.  This allows the assignment-check and fetch of the value to be done in a single command, which can be important in threaded applications with shared data, and when using weak tables.

Thread Safety

• 

The assigned command is thread-safe as of Maple 15.

• 

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

Examples

> 

n≔4

n≔4

(1)
> 

assigned⁡n

true

(2)
> 

assigned⁡n,nval

true

(3)
> 

nval

4

(4)

Table lookups can return unevaluated; using assigned or comparing against evaln of the indexed name will distinguish between a unevaluated lookup and a found value.

> 

a≔table⁡symmetric

a≔table⁡symmetric,

(5)
> 

a1,2≔x

a1,2≔x

(6)
> 

assigned⁡a1,2

true

(7)
> 

assigned⁡a2,1

true

(8)
> 

assigned⁡a1,1

false

(9)
> 

assigned⁡abs⁡x

false

(10)
> 

assigned⁡abs⁡2

true

(11)

assigned will evaluate the function to determine if it will return itself or not

> 

f := proc(x) `if`(x::integer,x^2,'procname'(x)) end:

> 

assigned⁡f

true

(12)
> 

assigned⁡f⁡x

false

(13)
> 

assigned⁡f⁡2

true

(14)

If you place an assumption on a name using the assume command, the assigned command returns true for that name.

> 

assigned⁡b

false

(15)
> 

assume⁡b,positive

> 

assigned⁡b

true

(16)

Note: Evaluating an assigned call under an assumption (using the assuming command), returns true for a name only if it has a value different from its name.

> 

assigned⁡cassumingc::integer

false

(17)

Compatibility

• 

The assigned command was updated in Maple 2019.

• 

The val option was introduced in Maple 2019.

• 

For more information on Maple 2019 changes, see Updates in Maple 2019.

See Also

anames

assume

assuming

evaln

hasindex

unames