[ Type Testing | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

type_of(?Term, ?Type)

Succeeds if Type is the data type of the term Term.
?Term
Prolog term.
?Type
Atom or variable.

Description

The type of the term Term is unified with Type.

The types are atoms from the set: string, atom, var, integer, rational, float, breal, compound, handle, db_reference, goal.

Fail Conditions

Fails if Type is not the data type of Term or else if Type is an atom that is not in the above set.

Resatisfiable

No.

Exceptions

(5) type error
Type is instantiated, but not to an atom.

Examples

Success:
      type_of(X,T).         (gives T=var).
      type_of([1,2],T).     (gives T=compound).
      type_of([],atom).
      type_of(#,atom).
      type_of($,atom).
      type_of(*,atom).
      type_of(/,atom).
      type_of(\,atom).
      type_of("a",string).
      type_of(1,integer).
      type_of(123456789012345,integer).
      type_of(1_3,rational).
      type_of(1.0,float).
      type_of(0.99__1.01,breal).
      type_of(a(b),compound).
      record(k, a), recorded(k, _, R), type_of(R, db_reference).
      make_suspension(true,S), type_of(S, goal).
Fail:
      type_of(2.0,integer).
      type_of(2.0,float).
Error:
      type_of(2,"atom").  (Error 5).



See Also

atom / 1, compound / 1, free / 1, integer / 1, meta / 1, number / 1, nonground / 1, breal / 1, rational / 1, float / 1, float / 1, real / 1, string / 1, var / 1