23.2.5 Checking the type of the argument
The type command finds the type of its input.
The getType command is similar to type in that it
takes an object and returns the type, but it has different possible
return values. It is included for compatibility reasons.
-
getType takes
obj, an object.
- getType(obj) returns the type of
obj, which in this case means one of:
NUM, VAR, STR, EXPR,
NONE, PIC, MAT or FUNC.
Examples
Subtypes
Xcas has various types of lists; the subtype command
can determine what kind of list it is.
-
subtype takes
L, a list (in DOM_LIST).
- subtype(L) returns an integer indicating what type
of list L is.
The possible values are:
-
1 is L is a sequence.
- 2 if L is a set.
- 10 if L is a polynomial represented by a list (see
Section 10.1).
- 0 if L isn’t one of the above types of list.
Example
Object comparison
The compare operator compares two objects taking their
type into account.
-
compare takes two arguments:
a,b, two objects.
- compare(a,b) returns
-
1 (true) if type(a)<type(b) or if
type(a)=type(b) and a is less than b in the
ordering of their type.
- 0 (false) otherwise.
Examples
since "a" and "b" have the same type
(string) and "a" is less than "b" in the
string ordering.
If b is a formal variable:
since the type of "a" is string (the integer 12)
while the type of b is identifier (the integer 6)
and 12 is not less than 6.