<!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> Atomic term processing </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual041.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual043.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="htoc187">7.19</A></B></FONT></TD> <TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>Atomic term processing</B></FONT></TD> </TR></TABLE></DIV></TD> </TR></TABLE><UL> <LI><A HREF="manual042.html#toc147"> <TT>atom_length/2</TT></A> <LI><A HREF="manual042.html#toc148"> <TT>atom_concat/3</TT></A> <LI><A HREF="manual042.html#toc149"> <TT>sub_atom/5</TT></A> <LI><A HREF="manual042.html#toc150"> <TT>char_code/2</TT></A> <LI><A HREF="manual042.html#toc151"> <TT>lower_upper/2</TT></A> <LI><A HREF="manual042.html#toc152"> <TT>atom_chars/2</TT>, <TT>atom_codes/2</TT></A> <LI><A HREF="manual042.html#toc153"> <TT>number_atom/2</TT>, <TT>number_chars/2</TT>, <TT>number_codes/2</TT></A> <LI><A HREF="manual042.html#toc154"> <TT>name/2</TT></A> <LI><A HREF="manual042.html#toc155"> <TT>atom_hash/2</TT></A> <LI><A HREF="manual042.html#toc156"> <TT>new_atom/3</TT>, <TT>new_atom/2</TT>, <TT>new_atom/1</TT></A> <LI><A HREF="manual042.html#toc157"> <TT>current_atom/1</TT></A> <LI><A HREF="manual042.html#toc158"> <TT>atom_property/2</TT></A> </UL> These built-in predicates enable atomic terms to be processed as a sequence of characters and character codes. Facilities exist to split and join atoms, to convert a single character to and from the corresponding character code, and to convert a number to and from a list of characters and character codes.<BR> <BR> <A NAME="toc147"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc188">7.19.1</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>atom_length/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> atom_length(+atom, ?integer)</TT></DL> <B>Description</B><BR> <BR> <TT>atom_length(Atom, Length)</TT> succeeds if <TT>Length</TT> unifies with the number of characters of the name of <TT>Atom</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>Atom</TT> is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>Length</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Length)</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>Length</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Length)</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> ISO predicate.<BR> <BR> <A NAME="toc148"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc189">7.19.2</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>atom_concat/3</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> atom_concat(+atom, +atom, ?atom)<BR> atom_concat(?atom, ?atom, +atom)</TT></DL> <B>Description</B><BR> <BR> <TT>atom_concat(Atom1, Atom2, Atom12)</TT> succeeds if the name of <TT>Atom12</TT> is the concatenation of the name of <TT>Atom1</TT> with the name of <TT>Atom1</TT>. This predicate is re-executable on backtracking (e.g. if <TT>Atom12</TT> is instantiated and both <TT>Atom1</TT> and <TT>Atom2</TT> are variables).<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>Atom1</TT> and <TT>Atom12</TT> are variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom2</TT> and <TT>Atom12</TT> are variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom1</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom1)</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>Atom2</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom2)</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>Atom12</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom12)</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> ISO predicate.<BR> <BR> <A NAME="toc149"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc190">7.19.3</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>sub_atom/5</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> sub_atom(+atom, ?integer, ?integer, ?integer, ?atom)</TT></DL> <B>Description</B><BR> <BR> <TT>sub_atom(Atom, Before, Length, After, SubAtom)</TT> succeeds if atom <TT>Atom</TT> can be split into three atoms, <TT>AtomL</TT>, <TT>SubAtom</TT> and <TT>AtomR</TT> such that <TT>Before</TT> is the number of characters of the name of <TT>AtomL</TT>, <TT>Length</TT> is the number of characters of the name of <TT>SubAtom</TT> and <TT>After</TT> is the number of characters of the name of <TT>AtomR</TT>. This predicate is re-executable on backtracking.<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>Atom</TT> is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>SubAtom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, SubAtom)</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>Before</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Before)</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>Length</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Length)</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>After</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, After)</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>Before</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Before)</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>Length</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Length)</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>After</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, After)</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> ISO predicate.<BR> <BR> <A NAME="toc150"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc191">7.19.4</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>char_code/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="char-code/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> char_code(+character, ?character_code)<BR> char_code(-character, +character_code)</TT></DL> <B>Description</B><BR> <BR> <TT>char_code(Char, Code)</TT> succeeds if the character code for the one-char atom <TT>Char</TT> is <TT>Code</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>Char</TT> and <TT>Code</TT> are variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Char</TT> is neither a variable nor a one-char atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(character, Char)</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>Code</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Code)</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>Code</TT> is an integer but not a character code</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>representation_error(character_code)</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> ISO predicate.<BR> <BR> <A NAME="toc151"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc192">7.19.5</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>lower_upper/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> lower_upper(+character, ?character)<BR> lower_upper(-character, +character)</TT></DL> <B>Description</B><BR> <BR> <TT>lower_upper(Char1, Char2)</TT> succeeds if <TT>Char1</TT> and <TT>Char2</TT> are one-char atoms and if <TT>Char2</TT> is the upper conversion of <TT>Char1</TT>. If <TT>Char1</TT> (resp. <TT>Char2</TT>) is a character that is not a lower (resp. upper) letter then <TT>Char2</TT> is equal to <TT>Char1</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>Char1</TT> and <TT>Char2</TT> are variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Char1</TT> is neither a variable nor a one-char atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(character, Char1)</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>Char2</TT> is neither a variable nor a one-char atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(character, Char2)</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> <A NAME="toc152"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc193">7.19.6</A></B></TD> <TD WIDTH="100%" ALIGN=center><B><TT>atom_chars/2</TT>, <TT>atom_codes/2</TT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="atom-chars/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> atom_chars(+atom, ?character_list)<BR> atom_chars(-atom, +character_list)<BR> atom_codes(+atom, ?character_code_list)<BR> atom_codes(-atom, +character_code_list)</TT></DL> <B>Description</B><BR> <BR> <TT>atom_chars(Atom, Chars)</TT> succeeds if <TT>Chars</TT> is the list of one-char atoms whose names are the successive characters of the name of <TT>Atom</TT>.<BR> <BR> <TT>atom_codes(Atom, Codes)</TT> is similar to <TT>atom_chars/2</TT> but deals with a list of character codes.<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>Atom</TT> is a variable and <TT>Chars</TT> (or <TT>Codes</TT>) is a partial list or a list with an element which is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>Chars</TT> is neither a list nor a partial list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Chars)</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>Codes</TT> is neither a list nor a partial list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Codes)</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>Atom</TT> is a variable and an element <TT>E</TT> of the list <TT>Chars</TT> is neither a variable nor a one-char atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(character, E)</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>Atom</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, E)</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>Atom</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is an integer but not a character code</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>representation_error(character_code)</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> ISO predicates. The ISO reference only causes a <TT>type_error(list, Chars)</TT> if <TT>Atom</TT> is a variable and <TT>Chars</TT> is neither a list nor a partial list. GNU Prolog always checks if <TT>Chars</TT> is a list. Similarly for <TT>Codes</TT>. The <TT>type_error(integer, E)</TT> when an element <TT>E</TT> of the <TT>Codes</TT> is not an integer is a GNU Prolog extension. This seems to be an omission in the ISO reference since this error is detected for many other built-in predicates accepting a character code (e.g. <TT>char_code/2</TT>, <TT>put_code/2</TT>).<BR> <BR> <A NAME="toc153"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc194">7.19.7</A></B></TD> <TD WIDTH="100%" ALIGN=center><B><TT>number_atom/2</TT>, <TT>number_chars/2</TT>, <TT>number_codes/2</TT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="number-atom/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> number_atom(+number, ?atom)<BR> number_atom(-number, +atom)<BR> number_chars(+number, ?character_list)<BR> number_chars(-number, +character_list)<BR> number_codes(+number, ?character_code_list)<BR> number_codes(-number, +character_code_list)</TT></DL> <B>Description</B><BR> <BR> <TT>number_atom(Number, Atom)</TT> succeeds if <TT>Atom</TT> is an atom whose name corresponds to the characters of <TT>Number</TT>.<BR> <BR> <TT>number_chars(Number, Chars)</TT> is similar to <TT>number_atom/2</TT> but deals with a list of character codes.<BR> <BR> <TT>number_codes(Number, Codes)</TT> is similar to <TT>number_atom/2</TT> but deals with a list of characters.<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>Number</TT> and <TT>Atom</TT> are variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Number</TT> is a variable and <TT>Chars</TT> (or <TT>Codes</TT>) is a partial list or a list with an element which is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Number</TT> is neither a variable nor an number</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(number, Number)</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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>Number</TT> is a variable and <TT>Chars</TT> is neither a list nor a partial list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Chars)</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>Number</TT> is a variable and <TT>Codes</TT> is neither a list nor a partial list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Codes)</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>Number</TT> is a variable and an element <TT>E</TT> of the list <TT>Chars</TT> is neither a variable nor a one-char atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(character, E)</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>Number</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, E)</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>Number</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is an integer but not a character code</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>representation_error(character_code)</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>Number</TT> is a variable, <TT>Atom</TT> (or <TT>Chars</TT> or <TT>Codes</TT>) cannot be parsed as a number and the value of the <TT>syntax_error</TT> Prolog flag is <TT>error</TT> (section <A HREF="manual045.html#set-prolog-flag/2">7.22.1</A>)</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>syntax_error(<I>atom explaining the error</I>)</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>number_atom/2</TT> is a GNU Prolog predicate. <TT>number_chars/2</TT> and <TT>number_codes/2</TT> are ISO predicates.<BR> <BR> GNU Prolog only raises an error about an element <TT>E</TT> of the <TT>Chars</TT> (or <TT>Codes</TT>) list when <TT>Number</TT> is a variable while the ISO reference always check this. This seems an error since the list itself is only checked if <TT>Number</TT> is a variable.<BR> <BR> The <TT>type_error(integer, E)</TT> when an element <TT>E</TT> of the <TT>Codes</TT> is not an integer is a GNU Prolog extension. This seems to be an omission in the ISO reference since this error is detected for many other built-in predicates accepting a character code (e.g. <TT>char_code/2</TT>, <TT>put_code/2</TT>).<BR> <BR> <A NAME="toc154"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc195">7.19.8</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>name/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> name(+atomic, ?character_code_list)<BR> name(-atomic, +character_code_list)</TT></DL> <B>Description</B><BR> <BR> <TT>name(Constant, Codes)</TT> succeeds if <TT>Codes</TT> is a list whose elements are the character codes corresponding to the successive characters of <TT>Constant</TT> (a number or an atom). However, there atoms are for which <TT>name(Constant, Codes)</TT> is true, but which will not be constructed if <TT>name/2</TT> is called with <TT>Constant</TT> uninstantiated, e.g. the atom <TT>'1024'</TT>. For this reason the use of <TT>name/2</TT> is discouraged and should be limited to compatibility purposes. It is preferable to use atom_codes/2 (section <A HREF="#atom-chars/2">7.19.6</A>) or number_chars/2 (section <A HREF="#number-atom/2">7.19.7</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>Constant</TT> is a variable and <TT>Codes</TT> is a partial list or a list with an element which is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Constant</TT> is neither a variable nor an atomic term</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atomic, Constant)</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>Constant</TT> is a variable and <TT>Codes</TT> is neither a list nor a partial list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Codes)</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>Constant</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, E)</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>Constant</TT> is a variable and an element <TT>E</TT> of the list <TT>Codes</TT> is an integer but not a character code</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>representation_error(character_code)</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> <A NAME="toc155"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc196">7.19.9</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>atom_hash/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="atom-hash/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> atom_hash(+atom, ?integer)<BR> atom_hash(?atom, +integer)</TT></DL> <B>Description</B><BR> <BR> <TT>atom_hash(Atom, Hash)</TT> succeeds if <TT>Hash</TT> is the internal key associated to <TT>Atom</TT> (an existing atom). The internal key of an atom is a unique integer >= 0 and < to the <TT>max_atom</TT> Prolog flag (section <A HREF="manual045.html#set-prolog-flag/2">7.22.1</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>Atom</TT> and <TT>Hash</TT> are both variables</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>Hash</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Hash)</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>Hash</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Hash)</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> <A NAME="toc156"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc197">7.19.10</A></B></TD> <TD WIDTH="100%" ALIGN=center><B><TT>new_atom/3</TT>, <TT>new_atom/2</TT>, <TT>new_atom/1</TT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> new_atom(+atom, +integer, -atom)<BR> new_atom(+atom, -atom)<BR> new_atom(-atom)</TT></DL> <B>Description</B><BR> <BR> <TT>new_atom(Prefix, Hash, Atom)</TT> unifies <TT>Atom</TT> with a new atom whose name begins with the characters of the name of <TT>Prefix</TT> and whose internal key is <TT>Hash</TT> (section <A HREF="#atom-hash/2">7.19.9</A>). This predicate is then a symbol generator. It is guaranteed that <TT>Atom</TT> does not exist before the invocation of <TT>new_atom/3</TT>. The characters appended to <TT>Prefix</TT> to form <TT>Atom</TT> are in: <TT>A</TT>-<TT>Z</TT> (capital letter), <TT>a</TT>-<TT>z</TT> (small letter), <TT>0</TT>-<TT>9</TT> (digit), <TT>#</TT>, <TT>$</TT>, <TT>&</TT>, <TT>_</TT>, <TT>@</TT>.<BR> <BR> <TT>new_atom/2</TT> is similar to <TT>new_atom/3</TT>, but the atom generated can have any (free) internal key.<BR> <BR> <TT>new_atom/1</TT> is similar to <TT>new_atom(atom_, Atom)</TT>, i.e. the generated atom begins with <TT>atom_</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>Prefix</TT> is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Hash</TT> is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </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>Prefix</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Prefix)</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>Hash</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, Hash)</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>Hash</TT> is an integer < 0</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Hash)</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>Atom</TT> is not a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(variable, Atom)</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> <A NAME="toc157"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc198">7.19.11</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>current_atom/1</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="current-atom/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> current_atom(?atom)</TT></DL> <B>Description</B><BR> <BR> <TT>current_atom(Atom)</TT> succeeds if there exists an atom that unifies with <TT>Atom</TT>. All atoms are found except those beginning with a <TT>'$'</TT> (system atoms). This predicate is re-executable on backtracking.<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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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> <A NAME="toc158"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc199">7.19.12</A></B></TD> <TD WIDTH="100%" ALIGN=center><TT><B>atom_property/2</B></TT></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="atom-property/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> atom_property(?atom, ?atom_property)</TT></DL> <B>Description</B><BR> <BR> <TT>atom_property(Atom, Property)</TT> succeeds if <TT>current_atom(Atom)</TT> succeeds (section <A HREF="#current-atom/2">7.19.11</A>) and if <TT>Property</TT> unifies with one of the properties of the atom. This predicate is re-executable on backtracking.<BR> <BR> <B>Atom properties</B>: <UL><LI><TT>length(Length)</TT>: <TT>Length</TT> is the length of the name of the atom.<BR> <BR> <LI><TT>hash(Hash)</TT>: <TT>Hash</TT> is the internal key of the atom (section <A HREF="#atom-hash/2">7.19.9</A>).<BR> <BR> <LI><TT>prefix_op</TT>: if there is a prefix operator currently defined with this name.<BR> <BR> <LI><TT>infix_op</TT>: if there is an infix operator currently defined with this name.<BR> <BR> <LI><TT>postfix_op</TT>: if there is a postfix operator currently defined with this name.<BR> <BR> <LI><TT>needs_quotes</TT>: if the atom must be quoted to be read later.<BR> <BR> <LI><TT>needs_scan</TT>: if the atom must be scanned when output to be read later (e.g. contains special characters that must be output with a <TT>\</TT> escape sequence).</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>Atom</TT> is neither a variable nor an atom</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(atom, Atom)</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>Property</TT> is neither a variable nor a n atom property term</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(atom_property, Property)</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>Property</TT> = <TT>length(E)</TT> or <TT>hash(E)</TT> and <TT>E</TT> is neither a variable nor an integer</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(integer, E)</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="manual041.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual043.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>