Type::TableOf --
a type representing tables
IntroductionType::TableOf represents tables; the types of the indices and
of the entries can be specified.
Call(s)
testtype(obj,
Type::TableOf( <indices_type <, entries_type>>))
Parametersobj | - | 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. |
Returnssee testtype
Related Functionstesttype, table, Type::TableOfIndex, Type::TableOfEntry
Detailstesttype(obj, Type::TableOf(indices_type),
Type::TableOf(entries_type)) checks, whether obj is a
table with indices of type indices_type
and entries of type entries_type.indices_type and entries_type default to
Type::AnyType
Example 1We test if the following objects are tables:
>> testtype(x, Type::TableOf());
testtype(table(), Type::TableOf())
FALSE
TRUE
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))
FALSE
TRUE
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))
FALSE
TRUE
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))
FALSE
TRUE
Example 2Test if the following table uses identifiers as indexes:
>> T := table(a = 1, b = 2, c = 3, d = 4):
testtype(T, Type::TableOf(DOM_IDENT))
TRUE
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))
FALSE
>> delete T:
Example 3The 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))
TRUE
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))
FALSE
>> delete T:
Type::TableOf is a new function
MuPAD Combinat, an open source algebraic combinatorics package