Type Testing

Type testing allows checking terms for their type without an attempt to instantiate. These predicates are therefore meta-logical. The basic data types of the ISO Prolog core standard are variable, atom, integer, float and compound. The Jekejeke Prolog system adds to these data types the data types reference and decimal.

Examples:
?- callable(p(X,Y)).
Yes
?- callable(1).
No

We find elementary test predicates such as var/1, atom/1, integer/1, float/1 and compound/1. For the Jekejeke Prolog specific data types we find the test predicates reference/1, decimal/1, float32/1 and float64/1. We find also test predicates that group different data types together such as nonvar/1, atomic/1, number/1 and callable/1.

The following type testing predicates are provided:

integer(X): [ISO 8.3.3]
The predicate succeeds when X is an integer.
float(X): [ISO 8.3.4]
The predicate succeeds when X is a float.
atom(X): [ISO 8.3.2]
The predicate succeeds when X is a functor.
compound(X): [ISO 8.3.6]
The predicate succeeds when X is a compound.
reference(X):
The predicate succeeds when X is a reference.
decimal(X):
The predicate succeeds when X is a decimal.
number(X): [ISO 8.3.8]
The predicate succeeds when X is a number, i.e. an integer, a float or a decimal.
callable(X): [TC2 8.3.9]
The predicate succeeds when X is callable, i.e. an atom or a compound.
atomic(X): [ISO 8.3.5]
The predicate succeeds when X is a constant, i.e. an atom, a number or a reference.
var(X): [ISO 8.3.1]
The predicate succeeds when X is a variable.
nonvar(X): [ISO 8.3.7]
The predicate succeeds when X is not a variable, i.e. atomic or compound.
float32(X):
The predicate succeeds when X is a float32.
float64(X):
The predicate succeeds when X is a float64.

Comments