Previous Up Next

25.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.

Examples

type(4)
     
integer           
type(3.1)==DOM_FLOAT
     
true           
getType(3.14)
     
NUM           
getType(x)
     
VAR           

Subtypes

Xcas has various types of lists; the subtype command can determine what kind of list it is.

Example

subtype(1,2,3)
     
1           

Object comparison

The compare operator compares two objects taking their type into account.

Examples

compare("a","b")
     
1           

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:

compare("a",b)
     
0           

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.


Previous Up Next