Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > d1f06a5336fd6bf4a381b72b8d2b5ce1 > files > 161

gprolog-1.2.16-3mdk.ppc.rpm

<!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.06-7 of 2001-11-14">
<TITLE>
 Term comparison
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual025.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual027.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#66dbff"><DIV ALIGN=center><TABLE>
<TR><TD><FONT SIZE=4><B><A NAME="htoc72">7.3</A></B></FONT></TD>
<TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>Term comparison</B></FONT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><UL>
<LI><A HREF="manual026.html#toc48"> Standard total ordering of terms</A>
<LI><A HREF="manual026.html#toc49"> <TT>(==)/2</TT> - term identical,
 <TT>(\==)/2</TT> - term not identical,<BR>
<TT>(@&lt;)/2</TT> - term less than,
 <TT>(@=&lt;)/2</TT> - term less than or equal to,<BR>
<TT>(@&gt;)/2</TT> - term greater than,
 <TT>(@&gt;=)/2</TT> - term greater than or equal to</A>
<LI><A HREF="manual026.html#toc50"> <TT>compare/3</TT></A>
</UL>
<BR>
<A NAME="toc48"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc73">7.3.1</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B>Standard total ordering of terms</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="Standard-total-ordering-of-terms"></A>
The built-in predicates described in this section allows the user to compare
Prolog terms. Prolog terms are totally ordered according to the standard
total ordering of terms which is as follows (from the smallest term to the
greatest):
<UL><LI>variables, oldest first.<BR>
<BR>
<LI>finite domain variables (section&nbsp;<A HREF="manual055.html#Finite-Domain-variables">8.1.1</A>), oldest
first.<BR>
<BR>
<LI>floating point numbers, in numeric order. <BR>
<BR>
<LI>integers, in numeric order. <BR>
<BR>
<LI>atoms, in alphabetical (i.e. character code) order. <BR>
<BR>
<LI>compound terms, ordered first by arity, then by the name of the
principal functor and by the arguments in left-to-right order.</UL>
A list is treated as a compound term (whose principal functor is
<TT>'.'/2</TT>).<BR>
<BR>
The portability of the order of variables is not guaranteed (in the ISO
reference the oder of variables is system dependent).<BR>
<BR>
<A NAME="toc49"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc74">7.3.2</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B><TT>(==)/2</TT> - term identical,
 <TT>(\==)/2</TT> - term not identical,<BR>
<TT>(@&lt;)/2</TT> - term less than,
 <TT>(@=&lt;)/2</TT> - term less than or equal to,<BR>
<TT>(@&gt;)/2</TT> - term greater than,
 <TT>(@&gt;=)/2</TT> - term greater than or equal to</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="(==)/2"></A> 
 
 
 
 
 
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
==(?term, ?term)<BR>
\==(?term, ?term)<BR>
@&lt;(?term, ?term)<BR>
@=&lt;(?term, ?term)<BR>
@&gt;(?term, ?term)<BR>
@&gt;=(?term, ?term)</TT></DL>
<B>Description</B><BR>
<BR>
These predicates compare two terms according to the standard total ordering
of terms (section&nbsp;<A HREF="#Standard-total-ordering-of-terms">7.3.1</A>).<BR>
<BR>
<TT>Term1 == Term2</TT> succeeds if <TT>Term1</TT> and <TT>Term2</TT> are
equal. <BR>
<BR>
<TT>Term1 \== Term2</TT> succeeds if <TT>Term1</TT> and
<TT>Term2</TT> are different.<BR>
<BR>
<TT>Term1 @&lt; Term2</TT> succeeds if <TT>Term1</TT> is less than
<TT>Term2</TT>.<BR>
<BR>
<TT>Term1 @=&lt; Term2</TT> succeeds if <TT>Term1</TT> is less than or
equal to <TT>Term2</TT>.<BR>
<BR>
<TT>Term1 @&gt; Term2</TT> succeeds if <TT>Term1</TT> is greater than
<TT>Term2</TT>.<BR>
<BR>
<TT>Term1 @&gt;= Term2</TT> succeeds if <TT>Term1</TT> is greater than
or equal to <TT>Term2</TT>.<BR>
<BR>
<TT>==</TT>, <TT>\==</TT>, <TT>@&lt;</TT>, <TT>@=&lt;</TT>,
<TT>@&gt;</TT> and <TT>@&gt;=</TT> are predefined infix operators (section&nbsp;<A HREF="manual037.html#op/3:(Term-input/output)">7.14.10</A>).<BR>
<BR>
<B>Errors</B><BR>
<BR>
None.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO predicates.<BR>
<BR>
<A NAME="toc50"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc75">7.3.3</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>compare/3</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
compare(?atom, +term, +term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>compare(Result, Term1, Term2)</TT> compares <TT>Term1</TT> and
<TT>Term2</TT> according to the standard (section&nbsp;<A HREF="#Standard-total-ordering-of-terms">7.3.1</A>) and unifies <TT>Result</TT> with:
<UL><LI>the atom <TT>&lt;</TT> if <TT>Term1</TT> is less than <TT>Term2</TT>.<BR>
<BR>
<LI>the atom <TT>=</TT> if <TT>Term1</TT> and <TT>Term2</TT> are equal.<BR>
<BR>
<LI>the atom <TT>&gt;</TT> if <TT>Term1</TT> is greater than
<TT>Term2</TT>.</UL>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Result</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Result)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>

<HR SIZE=2>
Copyright (C) 1999-2002 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="manual025.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual027.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>