Up Next

8.1  Type testing

8.1.1  var/1, nonvar/1, atom/1, integer/1, float/1, number/1, atomic/1,
compound/1, callable/1, ground/1, is_list/1, list/1,
partial_list/1, list_or_partial_list/1

Templates

var(?term)
nonvar(?term)
atom(?term)
integer(?term)
float(?term)
number(?term)
atomic(?term)
compound(?term)
callable(?term)
ground(?term)
is_list(?term)
list(?term)
partial_list(?term)
list_or_partial_list(?term)

Description

var(Term) succeeds if Term is currently uninstantiated (which therefore has not been bound to anything, except possibly another uninstantiated variable).

nonvar(Term) succeeds if Term is currently instantiated (opposite of var/1).

atom(Term) succeeds if Term is currently instantiated to an atom.

integer(Term) succeeds if Term is currently instantiated to an integer.

float(Term) succeeds if Term is currently instantiated to a floating point number.

number(Term) succeeds if Term is currently instantiated to an integer or a floating point number.

atomic(Term) succeeds if Term is currently instantiated to an atom, an integer or a floating point number.

compound(Term) succeeds if Term is currently instantiated to a compound term, i.e. a term of arity > 0 (a list or a structure).

callable(Term) succeeds if Term is currently instantiated to a callable term, i.e. an atom or a compound term.

ground(Term) succeeds if Term is a ground term.

list(Term) succeeds if Term is currently instantiated to a list, i.e. the atom [] (empty list) or a term with principal functor ’.’/2 and with second argument (the tail) a list.

is_list(Term) behaves like list(Term) (for compatibility purpose).

partial_list(Term) succeeds if Term is currently instantiated to a partial list, i.e. a variable or a term whose the main functor is ’.’/2 and the second argument (the tail) is a partial list.

list_or_partial_list(Term) succeeds if Term is currently instantiated to a list or a partial list.

Errors

None.

Portability

var/1, nonvar/1, atom/1, integer/1, float/1, number/1, atomic/1, compound/1 callable/1 and ground/1 are ISO predicates.

list/1, partial_list/1 and list_or_partial_list/1 are GNU Prolog predicates.


Copyright (C) 1999-2013 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright
Up Next