commands → type

type(A,...)

The type command tests the type of an expression A. The known types are integer, rational, numeric, variable, function, polynomial, vector, and matrix. For vector and matrix types, the subtype of the elements can be specified as an optional third argument.

Examples

# test for integer
type(2,integer);
	1

# test for rational
type(1/2,rational);
	1

# test for numeric
type(2.0,numeric);
	1

# test for variable
type(x,variable);
	1

# test for function
type(sin(x),function);
	1

# test for polynomial
type(x^2,polynomial);
	1

# test for vector
type([1,2],vector);
	1

# test for matrix
type([[1,2],[3,4]],matrix);
	1

# test for vector of integers
type([1,2],vector,integer);
	1

# test for a numeric matrix
type([[1,2.0],[3.0,4]],matrix,numeric);
	1