[Next] [Contents]

## `Type::Intersection` -- a type representing the intersection of several types

#### Introduction

``Type::Intersection`(type1, type2...)` represents all objects having all of the types `type1, type2...`

#### Call(s)

`testtype(obj, `Type::Intersection(`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::Intersection(`obj_types...`)`)` checks, whether `obj` has all the given types obj_types....

- The call `testtype(obj, `Type::Intersection(`obj_types...`)`)` is thus equivalent to the call `_lazy_and(`map(obj_types, x -> testtype(obj, x))`)`, testing `obj` against all types in turn.

- 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 and odd integer:

    >> testtype(1, Type::Intersection(Type::PosInt, Type::Odd))

                                       TRUE

`2` however, is not a positive and a odd number:

    >> testtype(2, Type::Intersection(Type::PosInt, Type::Odd))

                                       FALSE

#### Example 2

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

    >> SET:= {-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 3}:
       select(SET, testtype, Type::Intersection(Type::PosInt, Type::Odd))

                                      {1, 3}

    >> delete SET:

#### Changes

- `Type::Intersection` is a new function

[Next] [Contents]

MuPAD Combinat, an open source algebraic combinatorics package