## `Type::Union` -- type for testing several types with one call

#### Introduction

``Type::Union`(type1, type2...)` represents all objects having at least one of the types `type1, type2...`

#### Call(s)

`testtype(obj,` Type::Union(obj_types...`)`)

#### Parameters

`obj` | - | any MuPAD object
`obj_types` | - | a sequence of types; a type can be an object of the library `Type` or one of the possible return values of `domtype` and `type`

#### Returns

see `testtype`

#### Related Functions

`testtype`

#### Details

- The call `testtype(obj,` Type::Union(obj_types...`)`) checks, whether `obj` has the type of at least one of the given types obj_types... If such a type is found, the call returns `TRUE`, otherwise `FALSE`.
- The call `testtype(obj,` Type::Union(obj_types...`)`) is thus equivalent to the call `_lazy_or(`map(obj_types, x -> testtype(obj, x))), testing `obj` against all types in turn until one is found which matches.
- obj_types... must be a (nonempty) sequence of types (see `testtype`).
- This type does not represent a property.

#### Example 1

Check, whether the given object is a positive or negative integer:

    >> testtype(2, Type::Union(Type::PosInt, Type::NegInt))

                                       TRUE

`x` however, is neither a positive nor a negative number:

    >> testtype(x, Type::Union(Type::Positive, Type::Negative))

                                       FALSE

#### Example 2

`testtype` is used to select positive and negative integers:

    >> SET:= {-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2}:
       select(SET, testtype, Type::Union(Type::PosInt, Type::NegInt))

                                  {-2, -1, 1, 2}

    >> delete SET:

#### Changes

- no changes

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