Sophie

Sophie

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

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>
 Logic, control and exceptions
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual040.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual042.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="htoc182">7.18</A></B></FONT></TD>
<TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>Logic, control and exceptions</B></FONT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><UL>
<LI><A HREF="manual041.html#toc143"> <TT>abort/0</TT>,
 <TT>stop/0</TT>,
 <TT>top_level/0</TT>,
 <TT>break/0</TT>,
 <TT>halt/1</TT>,
 <TT>halt/0</TT></A>
<LI><A HREF="manual041.html#toc144"> <TT>once/1</TT>, <TT>(\+)/1</TT> - not provable,
 <TT>call_with_args/1-11</TT>, <TT>call/2</TT></A>
<LI><A HREF="manual041.html#toc145"> <TT>repeat/0</TT></A>
<LI><A HREF="manual041.html#toc146"> <TT>for/3</TT></A>
</UL>
<BR>
<A NAME="toc143"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc183">7.18.1</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B><TT>abort/0</TT>,
 <TT>stop/0</TT>,
 <TT>top_level/0</TT>,
 <TT>break/0</TT>,
 <TT>halt/1</TT>,
 <TT>halt/0</TT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="abort/0"></A>
 
 
 
 
 
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
abort<BR>
stop<BR>
top_level<BR>
break<BR>
halt(+integer)<BR>
halt</TT></DL>
<B>Description</B><BR>
<BR>
<TT>abort</TT> aborts the current execution. If this execution was initiated
under a top-level the control is given back to the top-level and the
message <TT>{execution aborted}</TT> is displayed. Otherwise,
e.g. execution started by a <TT>initialization/1</TT> directive
(section&nbsp;<A HREF="manual021.html#initialization/1">6.1.13</A>), <TT>abort/0</TT> is equivalent to
<TT>halt(1)</TT> (see below).<BR>
<BR>
<TT>stop</TT> stops the current execution. If this execution was initiated
under a top-level the control is given back to the
top-level. Otherwise, <TT>stop/0</TT> is equivalent to <TT>halt(0)</TT>
(see below).<BR>
<BR>
<TT>top_level</TT> starts a new recursive top-level (including the
banner display). To end this new top-level simply type the end-of-file
key sequence (<TT>Ctl-D</TT>) or its term representation:
<TT>end_of_file.</TT><BR>
<BR>
<TT>break</TT> invokes a recursive top-level (no banner is displayed). To
end this new level simply type the end-of-file key sequence (<TT>Ctl-D</TT>)
or its term representation: <TT>end_of_file.</TT><BR>
<BR>
<TT>halt(Status)</TT> causes the GNU Prolog process to immediately exit back to
the shell with the return code <TT>Status</TT>.<BR>
<BR>
<TT>halt</TT> is equivalent to <TT>halt(0)</TT>.<BR>
<BR>
<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>Status</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</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>
<TR><TD VALIGN=top ALIGN=left><TT>Status</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Status)</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>
<TT>halt/1</TT> and <TT>halt/0</TT> are ISO predicates. <TT>abort/0</TT>,
<TT>stop/0</TT>, <TT>top_level/0</TT> and <TT>break/0</TT> are GNU Prolog
predicates.<BR>
<BR>
<A NAME="toc144"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc184">7.18.2</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B><TT>once/1</TT>, <TT>(\+)/1</TT> - not provable,
 <TT>call_with_args/1-11</TT>, <TT>call/2</TT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 
 
 
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
once(+callable_term)<BR>
\+(+callable_term)<BR>
call_with_args(+atom, +term,..., +term)<BR>
call(+callable_term, ?boolean)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>once(Goal)</TT> succeeds if <TT>call(Goal)</TT> succeeds. However
<TT>once/1</TT> is not re-executable on backtracking since all alternatives
of <TT>Goal</TT> are cut. <TT>once(Goal)</TT> is equivalent to
<TT>call(Goal), !</TT>.<TT><BR>
<BR>
\+ Goal</TT> succeeds if <TT>call(Goal)</TT> fails and fails
otherwise. This built-in predicate gives negation by failure.<BR>
<BR>
<TT>call_with_args(Functor, Arg1,..., ArgN)</TT> calls the goal whose functor is <TT>Functor</TT> and whose arguments are <TT>Arg1</TT>,..., <TT>ArgN</TT> (0 &lt;= <TT>N</TT> &lt;= 10).<BR>
<BR>
<TT>call(Goal, Deterministic)</TT> succeeds if <TT>call(Goal)</TT>
succeeds and unifies <TT>Deterministic</TT> with <TT>true</TT> if
<TT>Goal</TT> has not created any choice-points, with <TT>false</TT>
otherwise.<TT><BR>
<BR>
\+</TT> is a predefined prefix operator (section&nbsp;<A HREF="manual037.html#op/3:(Term-input/output)">7.14.10</A>).<BR>
<BR>
<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>Goal</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</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>
<TR><TD VALIGN=top ALIGN=left><TT>Goal</TT> is neither a variable nor a callable term</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(callable, Goal)</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>
<TR><TD VALIGN=top ALIGN=left>The predicate indicator <TT>Pred</TT> of <TT>Goal</TT> does not
correspond to an existing procedure and the value of the <TT>unknown</TT>
Prolog flag is <TT>error</TT> (section&nbsp;<A HREF="manual045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(procedure, Pred)</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>
<TR><TD VALIGN=top ALIGN=left><TT>Functor</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</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>
<TR><TD VALIGN=top ALIGN=left><TT>Functor</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, Functor)</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>
<TR><TD VALIGN=top ALIGN=left><TT>Deterministic</TT> is neither a variable nor a boolean</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(boolean, Deterministic)</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>
<TT>once/1</TT> and <TT>(\+)/1</TT> are ISO predicates, <TT>call_with_args/1-11</TT> and <TT>call/2</TT> are GNU Prolog predicates.<BR>
<BR>
<A NAME="toc145"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc185">7.18.3</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>repeat/0</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
repeat</TT></DL>
<B>Description</B><BR>
<BR>
<TT>repeat</TT> generates an infinite sequence of backtracking choices. The
purpose is to repeatedly perform some action on elements which are somehow
generated, e.g. by reading them from a stream, until some test becomes true.
Repeat loops cannot contribute to the logic of the program. They are only
meaningful if the action involves side-effects. The only reason for using
repeat loops instead of a more natural tail-recursive formulation is
efficiency: when the test fails back, the Prolog engine immediately reclaims
any working storage consumed since the call to <TT>repeat/0</TT>.<BR>
<BR>
<B>Errors</B><BR>
<BR>
None.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO predicate. <BR>
<BR>
<A NAME="toc146"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc186">7.18.4</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>for/3</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
for(?integer, +integer, +integer)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>for(Counter, Lower, Upper)</TT> generates an sequence of backtracking
choices instantiating <TT>Counter</TT> to the values <TT>Lower</TT>,
<TT>Lower+1</TT>,..., <TT>Upper</TT>. <BR>
<BR>
<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>Counter</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Counter)</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>
<TR><TD VALIGN=top ALIGN=left><TT>Lower</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</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>
<TR><TD VALIGN=top ALIGN=left><TT>Lower</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Lower)</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>
<TR><TD VALIGN=top ALIGN=left><TT>Upper</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</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>
<TR><TD VALIGN=top ALIGN=left><TT>Upper</TT> is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Upper)</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="manual040.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual042.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>