[Up] [Contents] [Index] [Summary]
- int PL_term_type(term_t)
-
Obtain the type of a term, which should be a term returned by one of the
other interface predicates or passed as an argument. The function
returns the type of the Prolog term. The type identifiers are listed
below. Note that the extraction functions PL_ge_t*() also
validate the type and thus the two sections below are equivalent.
if ( PL_is_atom(t) )
{ char *s;
PL_get_atom_chars(t, &s);
...;
}
or
char *s;
if ( PL_get_atom_chars(t, &s) )
{ ...;
}
PL_VARIABLE | An
unbound variable. The value of term as such is a unique identifier for
the variable. |
PL_ATOM | A Prolog atom. |
PL_STRING | A Prolog string. |
PL_INTEGER | A Prolog integer. |
PL_FLOAT | A Prolog floating point
number. |
PL_TERM | A compound term. Note that a
list is a compound term ./2 . |
The functions PL_is_<type> are an alternative to
PL_term_type(). The test PL_is_var(term)
is equivalent to PL_term_type(term)
== PL_VARIABLE
, but the first is considerably faster. On the
other hand, using a switch over PL_term_type() is faster and more
readable then using an if-then-else using the functions below. All these
functions return either TRUE
or FALSE
.
- int PL_is_variable(term_t)
-
Returns non-zero if term is a variable.
- int PL_is_atom(term_t)
-
Returns non-zero if term is an atom.
- int PL_is_string(term_t)
-
Returns non-zero if term is a string.
- int PL_is_integer(term_t)
-
Returns non-zero if term is an integer.
- int PL_is_float(term_t)
-
Returns non-zero if term is a float.
- int PL_is_compound(term_t)
-
Returns non-zero if term is a compound term.
- int PL_is_functor(term_t,
functor_t)
-
Returns non-zero if term is compound and its functor is functor.
This test is equivalent to PL_get_functor(), followed by testing the
functor, but easier to write and faster.
- int PL_is_list(term_t)
-
Returns non-zero if term is a compound term with functor ./2
or the atom
.
- int PL_is_atomic(term_t)
-
Returns non-zero if term is atomic (not variable or
compound).
- int PL_is_number(term_t)
-
Returns non-zero if term is an integer or float.