Type::Union
-- type for testing
several types with one call
represents
all objects having at least one of the types Type::Union
(type1, type2...)type1,
type2...
testtype(obj,
Type::Union(obj_types...)
)
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 |
see testtype
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
.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.testtype
).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
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: