Type::ListProduct -- type
for testing lists
IntroductionWith Type::ListProduct, lists with different object
types can be identified.
Call(s)testtype(obj,
Type::ListProduct(typedef...))
Parametersobj |
- | any MuPAD object |
typedef |
- | 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 |
Returnssee testtype
Related
Functionstesttype, Type::ListOf, Type::Product
Detailstesttype(obj,
Type::ListProduct(typedef)) checks, whether
obj is a list of objects, which have the types given by
typedef and returns TRUE, if it holds, otherwise FALSE.obj must have the same number of arguments as the
sequence typedef. The elements of obj are
checked one after another: the first element of obj is
checked against the type given by the first element of
typedef, and so on. All elements and types must
match.Type::ListProduct(typedef...).Type or
one of the possible return values of domtype and type.
Example
1The argument is a list of a positive integer followed by an identifier:
>> testtype([5, x], Type::ListProduct(Type::PosInt, Type::Unknown))
TRUE
Is the argument is a list of a five positive integers?
(We use $ here to repeat
Type::PosInt five
times.)
>> testtype([5, 3, 5, -1, 0], Type::ListProduct(Type::PosInt $ 5))
FALSE