Type::TableOf

Type representing tables

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

testtype(obj, (<indices_type, <entries_type>>))

Description

Type::TableOf represents tables; the types of the indices and of the entries can be specified.

The call testtype(obj, Type::TableOf(indices_type, entries_type)) checks, whether obj is a table with indices of type indices_type and entries of type entries_type.

The indices (resp. the entries) of a table are the left (resp. right) hand sides of the operands of a table.

indices_type and entries_type default to Type::AnyType

This type does not represent a property.

Examples

Example 1

We test if the following objects are tables:

testtype(x, Type::TableOf());
testtype(table(), Type::TableOf())

We test if the following objects are tables with integer indexes:

testtype(table(a = 1), Type::TableOf(Type::Integer));
testtype(table(1 = 2), Type::TableOf(Type::Integer))

We test if the following objects are tables with integer entries:

testtype(table(a = a), Type::TableOf(Type::AnyType, Type::Integer));
testtype(table(a = 2), Type::TableOf(Type::AnyType, Type::Integer))

We test if the following objects are tables with integer indexes and entries:

testtype(table(a = a), Type::TableOf(Type::Integer, Type::Integer));
testtype(table(1 = 2), Type::TableOf(Type::Integer, Type::Integer))

Example 2

Test if the following table uses identifiers as indexes:

T := table(a = 1, b = 2, c = 3, d = 4):
testtype(T, Type::TableOf(DOM_IDENT))

Test if the following table uses integers as indexes:

T := table(a = 1, b = 2, c = 3, d = 4):
testtype(T, Type::TableOf(DOM_INT))

delete T:

Example 3

The following table uses identifiers as keys and integers as entries:

T := table(a = 1, b = 2, c = 3, d = 4):
testtype(T, Type::TableOf(Type::AnyType, DOM_INT))

Type::TableOf only checks the type of the entries, not the keys:

T := table(a = 1, b = 2, c = 3, d = 4):
testtype(T, Type::TableOf(Type::AnyType, DOM_IDENT))

delete T:

Parameters

obj

Any MuPAD® object

indices_type

The type of the indices. It can be an object of the library Type or one of the possible return values of domtype and type

entries_type

The type of the entries.

Return Values

See testtype

See Also

MuPAD Functions

Was this topic helpful?