type/mutable
check if an object is or contains mutable objects
Calling Sequence
Parameters
Description
Examples
type(expr, mutable)
expr
-
expression
The type(expr, mutable) calling sequence returns true if if expr is a mutable object or contains mutable objects.
A mutable object is a Maple expression whose contents can change without its identity changing. The mutable objects in Maple are of type table (which includes array), rtable (which includes Array, Vector, and Matrix), module (which includes record and object), and procedure.
For example, an element in an Array can be changed, yet it is still the same Array, so an array is mutable. On the other hand, "changing" an element in a list creates a new list, and any references to the original list will not see the change. A list is immutable.
A procedure is considered mutable because it can have a remember table (even if it does not have the remember option).
type⁡3.14,mutable
false
type⁡table⁡,mutable
true
type⁡Vectorrow⁡a,b,c,mutable
In general, a list is not mutable.
L≔a,b,c,d
L0≔L
L0≔a,b,c,d
This does not change the lists in-place, and in fact this syntax for "changing" a list is only supported for small lists, as it is very inefficient.
L32≔e
L
a,b,c,e
The original lists are unchanged, because lists are not mutable.
L0
a,b,c,d
type⁡L,mutable
A list containing an Array is mutable because the Array is mutable.
L≔a,b,Array⁡c,d
L≔a,b,cd
L0≔a,b,cd
This changes the contents of the Array in-place, and thus the containing list is unaffected.
a,b,ce
See Also
remember
type
type/array
type/Array
type/Matrix
type/module
type/object
type/procedure
type/record
type/rtable
type/table
type/Vector
Download Help Document