## `type` -- the type of an object

#### Introduction

`type``(object)` returns the type of the object.

#### Call(s)

`type(object)`

#### Parameters

`object` | - | any MuPAD object

#### Returns

a domain type of type `DOM_DOMAIN` or a character string.

### Overloadable:

`object`

#### Related Functions

`coerce`, `domtype`, `hastype`, `testtype`, `Type`

#### Details

- If `object` is not an expression of domain type `DOM_EXPR`, then `type(object)` is equivalent to `domtype``(object)`, i.e., `type` returns the domain type of the object.
- If `object` is an expression of domain type `DOM_EXPR`, then its type is determined by its 0-th operand (the ``operator''). If the operator has a `"type"` slot, then `type` returns this value, which usually is a string. If the operator has no `"type"` slot, then `type` returns the string `"function"`.
- In contrast to most other functions, `type` does not flatten arguments that are expression sequences. Cf. example 4.
- `type` is a function of the system kernel.

#### Example 1

If an object is not an expression, its type equals its domain type:

    >> type(3)

                                      DOM_INT

#### Example 2

The operator of a sum is `_plus`; the type slot of that operator is `"_plus"`:

    >> type(x + y*z)

                                      "_plus"

`type` evaluates its argument: thereby, the difference of `x` and `y` becomes the sum of `x` and `(-1)*y`. Its type is not `"_subtract"`, but `"_plus"`:

    >> type(x - y)

                                      "_plus"

#### Example 3

If the operator of an expression is not a function environment having a type slot, the expression is of type `"function"`:

    >> type(f(2))

                                    "function"

#### Example 4

The following call to `type` is not regarded as a call with two arguments, because expression sequences in the argument are not flattened:

    >> type((2, 3))

                                    "_exprseq"

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000