QP_is_*()

Synopsis

     #include <quintus/quintus.h>
     
     int QP_is_variable(term)
     QP_term_ref term;
     
     int QP_is_atom(term)
     QP_term_ref term;
     
     int QP_is_integer(term)
     QP_term_ref term;
     
     int QP_is_float(term)
     QP_term_ref term;
     
     int QP_is_compound(term)
     QP_term_ref term;
     
     int QP_is_list(term)
     QP_term_ref term;
     
     int QP_is_db_reference(term)
     QP_term_ref term;
     
     int QP_is_atomic(term)
     QP_term_ref term;
     
     int QP_is_number(term)
     QP_term_ref term;
     

These C functions and macros can be used to test the type of the Prolog terms passed to C through the foreign interface.

Description


QP_is_variable()
(macro) returns a nonzero value if its argument is a Prolog variable; zero otherwise.
QP_is_atom()
(macro) returns a nonzero value if its argument is an atom; zero otherwise.
QP_is_integer()
(macro) returns a nonzero value if its argument is a Prolog integer; zero otherwise.
QP_is_float()
(macro) returns a nonzero value if its argument is a float; zero otherwise.
QP_is_compound()
(macro) returns a nonzero value if its argument is a compound Prolog term; zero otherwise.
QP_is_list()
(function) returns a nonzero value if its argument is a Prolog list; zero otherwise.
QP_is_db_reference()
(macro) returns a nonzero value if its argument is a database reference; zero otherwise.
QP_is_atomic()
(function) returns a nonzero value if its argument is an atomic Prolog object; zero otherwise.
QP_is_number()
(function) returns a nonzero value if its argument is a Prolog integer or float; zero otherwise.

Examples

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; { if (QP_is_atom(term)) { QP_printf("Term is an atom\n"); } else if (QP_is_integer(term)) { QP_printf("Term is an integer\n"); } else if (QP_is_float(term)) { QP_printf("Term is a float\n"); } else if (QP_is_variable(term)) { QP_printf("Term is a variable\n"); } else if (QP_is_db_reference(term)) { QP_printf("Term is a database reference\n"); } else if (QP_is_compound(term)) { if (QP_is_list(term)) { QP_printf("Term is a list\n"); } else { QP_printf("Term is a compound term\n"); } } else { QP_printf("Unrecognized term\n"); } }

See Also

QP_get_*(), QP_put_*(), QP_new_term_ref()