type/mutable - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Rtables, Arrays, Matrices, and Vectors : Type Checking : type/mutable

type/mutable

check if an object is or contains mutable objects

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

type(expr, mutable)

Parameters

expr

-

expression

Description

• 

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

Examples

type3.14,mutable

false

(1)

typetable,mutable

true

(2)

typeVectorrowa,b,c,mutable

true

(3)

In general, a list is not mutable.

La,b,c,d

La,b,c,d

(4)

L0L

L0a,b,c,d

(5)

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.

L32e

L32e

(6)

L

a,b,c,e

(7)

The original lists are unchanged, because lists are not mutable.

L0

a,b,c,d

(8)

typeL,mutable

false

(9)

A list containing an Array is mutable because the Array is mutable.

La,b,Arrayc,d

La,b,cd

(10)

L0L

L0a,b,cd

(11)

This changes the contents of the Array in-place, and thus the containing list is unaffected.

L32e

L32e

(12)

L

a,b,ce

(13)

L0

a,b,ce

(14)

typeL,mutable

true

(15)

See Also

remember

type

type/array

type/Array

type/Matrix

type/module

type/object

type/procedure

type/record

type/rtable

type/table

type/Vector