Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 1519

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>2.1 Strings</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html">- Up -</A></TD><TD><A href="node4.html#section.data.virtualstrings">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.data.strings"><H2><A name="section.data.strings">2.1 Strings</A></H2><P> Strings are lists of characters, with characters being small integers between 0 and 255. For the coding of characters with integers we use the ISO&nbsp;8859-1 standard&nbsp;<A href="bib.html#iso_8859_1">[ISO87]</A>. </P><P> There are special operations on strings, like testing whether a given value&nbsp;<CODE>X</CODE> is a string, by <CODE>{IsString&nbsp;X}</CODE><A name="label12"></A>. For transforming strings into atoms, integers, or floats the procedures </P><UL><LI><P><CODE>String<SPAN class="keyword">.</SPAN>toAtom</CODE><A name="label14"></A>, </P></LI><LI><P><CODE>String<SPAN class="keyword">.</SPAN>toInt</CODE><A name="label16"></A>, and </P></LI><LI><P><CODE>String<SPAN class="keyword">.</SPAN>toFloat</CODE><A name="label18"></A> </P></LI></UL><P> are provided. For testing whether a given string can be transformed into an atom, integer, or float, the procedures </P><UL><LI><P><CODE>String<SPAN class="keyword">.</SPAN>isAtom</CODE><A name="label20"></A>, </P></LI><LI><P><CODE>String<SPAN class="keyword">.</SPAN>isInt</CODE><A name="label22"></A>, and </P></LI><LI><P><CODE>String<SPAN class="keyword">.</SPAN>isFloat</CODE><A name="label24"></A> </P></LI></UL><P> are provided. </P><P> In addition, all functionality provided by the module <A name="label25"></A><SPAN class="index"><CODE>List</CODE></SPAN> is applicable. It is especially useful in combination with the functionality provided by the module <A name="label26"></A><SPAN class="index"><CODE>Char</CODE></SPAN>. </P><P> Suppose that after reading or receiving a string <CODE>S=<SPAN class="string">&quot;C@l!3E4aN#61!&quot;</SPAN></CODE> all characters which are neither uppercase nor lowercase letters must be filtered out. This is achieved by using a combination of <A name="label27"></A><SPAN class="index"><CODE>Filter</CODE></SPAN> and <CODE>Char<SPAN class="keyword">.</SPAN>isAlpha</CODE><A name="label29"></A>. Feeding: </P><DL class="anoymous"><DT><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A name="label30">{Filter S}</A><SPAN class="chunkborder">&gt;=</SPAN></SPAN></DT><DD class="code"><CODE>{Browse&nbsp;{String<SPAN class="keyword">.</SPAN>toAtom&nbsp;{Filter&nbsp;S&nbsp;Char<SPAN class="keyword">.</SPAN>isAlpha}}}</CODE></DD></DL><P> will show the cleaned information in the browser window. </P><P> Instead of creating an atom from the cleaned string, the browser offers functionality to display strings directly in a convenient form. The functionality can be selected in the <SPAN class="menu">Representation, Type</SPAN> option, see also <A href="../browser/index.html">``The Oz Browser''</A>. For Example, </P><DL class="anoymous"><DT><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A name="label31">{Browse S}</A><SPAN class="chunkborder">&gt;=</SPAN></SPAN></DT><DD class="code"><CODE>{Browse&nbsp;{Filter&nbsp;S&nbsp;Char<SPAN class="keyword">.</SPAN>isAlpha}}</CODE></DD></DL><P> displays in the browser window the character sequence <CODE><SPAN class="string">&quot;ClEaN&quot;</SPAN></CODE>. </P><P> Remember that character codes for letters are syntactically supported. For instance, the string </P><BLOCKQUOTE class="code"><CODE><SPAN class="string">&quot;hi&nbsp;there&quot;</SPAN></CODE></BLOCKQUOTE><P> can be written equivalently as </P><BLOCKQUOTE class="code"><CODE>[<SPAN class="string">&amp;h</SPAN>&nbsp;<SPAN class="string">&amp;i</SPAN>&nbsp;<SPAN class="string">&amp;&nbsp;</SPAN>&nbsp;<SPAN class="string">&amp;t</SPAN>&nbsp;<SPAN class="string">&amp;h</SPAN>&nbsp;<SPAN class="string">&amp;e</SPAN>&nbsp;<SPAN class="string">&amp;r</SPAN>&nbsp;<SPAN class="string">&amp;e</SPAN>]</CODE></BLOCKQUOTE><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html">- Up -</A></TD><TD><A href="node4.html#section.data.virtualstrings">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>