1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>
Type testing
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog025.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H3 CLASS="subsection"><A NAME="htoc66">7.1</A> Type testing</H3><UL>
<LI><A HREF="gprolog024.html#toc44"><TT>var/1</TT>,
<TT>nonvar/1</TT>,
<TT>atom/1</TT>,
<TT>integer/1</TT>,
<TT>float/1</TT>,
<TT>number/1</TT>,
<TT>atomic/1</TT>,<BR>
<TT>compound/1</TT>,
<TT>callable/1</TT>,
<TT>list/1</TT>,
<TT>partial_list/1</TT>,
<TT>list_or_partial_list/1</TT></A>
</UL>
<A NAME="toc44"></A>
<H4 CLASS="subsubsection"><A NAME="htoc67">7.1.1</A> <TT>var/1</TT>,
<TT>nonvar/1</TT>,
<TT>atom/1</TT>,
<TT>integer/1</TT>,
<TT>float/1</TT>,
<TT>number/1</TT>,
<TT>atomic/1</TT>,<BR>
<TT>compound/1</TT>,
<TT>callable/1</TT>,
<TT>list/1</TT>,
<TT>partial_list/1</TT>,
<TT>list_or_partial_list/1</TT></H4>
<A NAME="var/1"></A>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
var(?term)<BR>
nonvar(?term)<BR>
atom(?term)<BR>
integer(?term)<BR>
float(?term)<BR>
number(?term)<BR>
atomic(?term)<BR>
compound(?term)<BR>
callable(?term)<BR>
list(?term)<BR>
partial_list(?term)<BR>
list_or_partial_list(?term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>var(Term)</TT> succeeds if <TT>Term</TT> is currently
uninstantiated (which therefore has not been bound to anything, except
possibly another uninstantiated variable).<BR>
<BR>
<TT>nonvar(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
(opposite of <TT>var/1</TT>).<BR>
<BR>
<TT>atom(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
to an atom.<BR>
<BR>
<TT>integer(Term)</TT> succeeds if <TT>Term</TT> is currently
instantiated to an integer.<BR>
<BR>
<TT>float(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
to a floating point number.<BR>
<BR>
<TT>number(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
to an integer or a floating point number.<BR>
<BR>
<TT>atomic(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
to an atom, an integer or a floating point number.<BR>
<BR>
<TT>compound(Term)</TT> succeeds if <TT>Term</TT> is currently
instantiated to a compound term, i.e. a term of arity > 0 (a list or a
structure).<BR>
<BR>
<TT>callable(Term)</TT> succeeds if <TT>Term</TT> is currently
instantiated to a callable term, i.e. an atom or a compound term.<BR>
<BR>
<TT>list(Term)</TT> succeeds if <TT>Term</TT> is currently instantiated
to a list, i.e. the atom <TT>[]</TT> (empty list) or a term with principal
functor <TT>'.'/2</TT> and with second argument (the tail) a list.<BR>
<BR>
<TT>partial_list(Term)</TT> succeeds if <TT>Term</TT> is currently
instantiated to a partial list, i.e. a variable or a term whose the main
functor is <TT>'.'/2</TT> and the second argument (the tail) is a partial
list.<BR>
<BR>
<TT>list_or_partial_list(Term)</TT> succeeds if <TT>Term</TT> is
currently instantiated to a list or a partial list.<BR>
<BR>
<B>Errors</B><BR>
<BR>
None.<BR>
<BR>
<B>Portability</B><BR>
<BR>
<TT>var/1</TT>, <TT>nonvar/1</TT>, <TT>atom/1</TT>, <TT>integer/1</TT>,
<TT>float/1</TT>, <TT>number/1</TT>, <TT>atomic/1</TT>, <TT>compound/1</TT>
and <TT>callable/1</TT> are ISO predicates.<BR>
<BR>
<TT>list/1</TT>, <TT>partial_list/1</TT> and
<TT>list_or_partial_list/1</TT> are GNU Prolog predicates.<BR>
<BR>
<HR SIZE=2>
Copyright (C) 1999-2007 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog025.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|