QP_term_type() #include <quintus/quintus.h>
int QP_term_type(term)
QP_term_ref term;
Tests the type of Prolog terms in C.
QP_term_type() returns the type of a
Prolog term that is passed to it as argument. The returned value is one of
the following constants defined in the file <quintus/quintus.h>:
QP_VARIABLE, QP_INTEGER, QP_ATOM,
QP_FLOAT or QP_COMPOUND.
print_type() is a C function that prints the type of
the Prolog term passed to it.
foo.pl
foreign(print_type, c, print_type(+term)).
foo.c
#include <quintus/quintus.h>
void print_type(term)
QP_term_ref term;
{
switch (QP_term_type(term)) {
case QP_VARIABLE:
QP_printf("Term is a variable\n");
break;
case QP_INTEGER:
QP_printf("Term is an integer\n");
break;
case QP_FLOAT:
QP_printf("Term is a float\n");
break;
case QP_ATOM:
QP_printf("Term is an atom\n");
break;
case QP_COMPOUND:
if (QP_is_list(term)) {
QP_printf("Term is a list\n");
} else {
QP_printf("Term is a compound term\n");
}
break;
}
}
QP_is_*(), QP_get_*(), QP_put_*(),
QP_new_term_ref()