[Previous] [Contents]

## `Type::TableOf` -- a type representing tables

#### Introduction

`Type::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>>`)`)`

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

#### Returns

see `testtype`

#### Related Functions

`testtype`, `table`, `Type::TableOfIndex`, `Type::TableOfEntry`

#### Details

- The call `testtype(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`.

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

#### Example 1

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

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

                                       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:

#### Changes

- `Type::TableOf` is a new function
- Deprecates Type::TableOfEntry and Type::TableOfIndices

[Previous] [Contents]

MuPAD Combinat, an open source algebraic combinatorics package