<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Batteries.Incubator.Log.html"> <link rel="next" href="Batteries.Incubator.Bounded.html"> <link rel="Up" href="Batteries.Incubator.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of class methods" rel=Appendix href="index_methods.html"> <link title="Index of classes" rel=Appendix href="index_classes.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="BatArray" rel="Chapter" href="BatArray.html"> <link title="BatAvlTree" rel="Chapter" href="BatAvlTree.html"> <link title="BatBase64" rel="Chapter" href="BatBase64.html"> <link title="BatBig_int" rel="Chapter" href="BatBig_int.html"> <link title="BatBigarray" rel="Chapter" href="BatBigarray.html"> <link title="BatBitSet" rel="Chapter" href="BatBitSet.html"> <link title="BatBool" rel="Chapter" href="BatBool.html"> <link title="BatBounded" rel="Chapter" href="BatBounded.html"> <link title="BatBuffer" rel="Chapter" href="BatBuffer.html"> <link title="BatCache" rel="Chapter" href="BatCache.html"> <link title="BatChar" rel="Chapter" href="BatChar.html"> <link title="BatCharParser" rel="Chapter" href="BatCharParser.html"> <link title="BatComplex" rel="Chapter" href="BatComplex.html"> <link title="BatConcurrent" rel="Chapter" href="BatConcurrent.html"> <link title="BatDeque" rel="Chapter" href="BatDeque.html"> <link title="BatDigest" rel="Chapter" href="BatDigest.html"> <link title="BatDllist" rel="Chapter" href="BatDllist.html"> <link title="BatDynArray" rel="Chapter" href="BatDynArray.html"> <link title="BatEnum" rel="Chapter" href="BatEnum.html"> <link title="BatFile" rel="Chapter" href="BatFile.html"> <link title="BatFingerTree" rel="Chapter" href="BatFingerTree.html"> <link title="BatFloat" rel="Chapter" href="BatFloat.html"> <link title="BatFormat" rel="Chapter" href="BatFormat.html"> <link title="BatGc" rel="Chapter" href="BatGc.html"> <link title="BatGenlex" rel="Chapter" href="BatGenlex.html"> <link title="BatGlobal" rel="Chapter" href="BatGlobal.html"> <link title="BatHashcons" rel="Chapter" href="BatHashcons.html"> <link title="BatHashtbl" rel="Chapter" href="BatHashtbl.html"> <link title="BatHeap" rel="Chapter" href="BatHeap.html"> <link title="BatIMap" rel="Chapter" href="BatIMap.html"> <link title="BatIO" rel="Chapter" href="BatIO.html"> <link title="BatISet" rel="Chapter" href="BatISet.html"> <link title="BatInnerIO" rel="Chapter" href="BatInnerIO.html"> <link title="BatInnerPervasives" rel="Chapter" href="BatInnerPervasives.html"> <link title="BatInnerWeaktbl" rel="Chapter" href="BatInnerWeaktbl.html"> <link title="BatInt" rel="Chapter" href="BatInt.html"> <link title="BatInt32" rel="Chapter" href="BatInt32.html"> <link title="BatInt64" rel="Chapter" href="BatInt64.html"> <link title="BatInterfaces" rel="Chapter" href="BatInterfaces.html"> <link title="BatLazyList" rel="Chapter" href="BatLazyList.html"> <link title="BatLexing" rel="Chapter" href="BatLexing.html"> <link title="BatList" rel="Chapter" href="BatList.html"> <link title="BatLog" rel="Chapter" href="BatLog.html"> <link title="BatLogger" rel="Chapter" href="BatLogger.html"> <link title="BatMap" rel="Chapter" href="BatMap.html"> <link title="BatMarshal" rel="Chapter" href="BatMarshal.html"> <link title="BatMultiMap" rel="Chapter" href="BatMultiMap.html"> <link title="BatMultiPMap" rel="Chapter" href="BatMultiPMap.html"> <link title="BatMutex" rel="Chapter" href="BatMutex.html"> <link title="BatNativeint" rel="Chapter" href="BatNativeint.html"> <link title="BatNum" rel="Chapter" href="BatNum.html"> <link title="BatNumber" rel="Chapter" href="BatNumber.html"> <link title="BatOo" rel="Chapter" href="BatOo.html"> <link title="BatOptParse" rel="Chapter" href="BatOptParse.html"> <link title="BatOption" rel="Chapter" href="BatOption.html"> <link title="BatOrd" rel="Chapter" href="BatOrd.html"> <link title="BatParserCo" rel="Chapter" href="BatParserCo.html"> <link title="BatPathGen" rel="Chapter" href="BatPathGen.html"> <link title="BatPervasives" rel="Chapter" href="BatPervasives.html"> <link title="BatPrintexc" rel="Chapter" href="BatPrintexc.html"> <link title="BatPrintf" rel="Chapter" href="BatPrintf.html"> <link title="BatQueue" rel="Chapter" href="BatQueue.html"> <link title="BatRMutex" rel="Chapter" href="BatRMutex.html"> <link title="BatRandom" rel="Chapter" href="BatRandom.html"> <link title="BatRef" rel="Chapter" href="BatRef.html"> <link title="BatRefList" rel="Chapter" href="BatRefList.html"> <link title="BatResult" rel="Chapter" href="BatResult.html"> <link title="BatReturn" rel="Chapter" href="BatReturn.html"> <link title="BatScanf" rel="Chapter" href="BatScanf.html"> <link title="BatSeq" rel="Chapter" href="BatSeq.html"> <link title="BatSet" rel="Chapter" href="BatSet.html"> <link title="BatSplay" rel="Chapter" href="BatSplay.html"> <link title="BatStack" rel="Chapter" href="BatStack.html"> <link title="BatStream" rel="Chapter" href="BatStream.html"> <link title="BatString" rel="Chapter" href="BatString.html"> <link title="BatSubstring" rel="Chapter" href="BatSubstring.html"> <link title="BatSys" rel="Chapter" href="BatSys.html"> <link title="BatText" rel="Chapter" href="BatText.html"> <link title="BatTuple" rel="Chapter" href="BatTuple.html"> <link title="BatUChar" rel="Chapter" href="BatUChar.html"> <link title="BatUTF8" rel="Chapter" href="BatUTF8.html"> <link title="BatUnit" rel="Chapter" href="BatUnit.html"> <link title="BatUnix" rel="Chapter" href="BatUnix.html"> <link title="BatUref" rel="Chapter" href="BatUref.html"> <link title="BatVect" rel="Chapter" href="BatVect.html"> <link title="Batteries" rel="Chapter" href="Batteries.html"> <link title="BatteriesConfig" rel="Chapter" href="BatteriesConfig.html"> <link title="BatteriesPrint" rel="Chapter" href="BatteriesPrint.html"> <link title="BatteriesThread" rel="Chapter" href="BatteriesThread.html"> <link title="Extlib" rel="Chapter" href="Extlib.html"><title>Batteries user guide : Batteries.Incubator.Substring</title> </head> <body> <div class="navbar"><a class="pre" href="Batteries.Incubator.Log.html" title="Batteries.Incubator.Log">Previous</a> <a class="up" href="Batteries.Incubator.html" title="Batteries.Incubator">Up</a> <a class="post" href="Batteries.Incubator.Bounded.html" title="Batteries.Incubator.Bounded">Next</a> </div> <h1>Module <a href="type_Batteries.Incubator.Substring.html">Batteries.Incubator.Substring</a></h1> <pre><span class="keyword">module</span> Substring: <code class="type">BatSubstring</code></pre><hr width="100%"> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre> <div class="info "> <code class="code"><span class="constructor">Substring</span>.t</code> is the type of substrings of a basestring, an efficient representation of a piece of a string. <p> A substring (s,i,n) is valid if 0 <= i <= i+n <= size s, or equivalently, 0 <= i and 0 <= n and i+n <= size s. <p> A valid substring (s, i, n) represents the string s<code class="code">i...i+n-1</code>. <p> Invariant in the implementation: Any value of type <code class="code"><span class="constructor">Substring</span>.t</code> is valid.<br> </div> <pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">unit -> <a href="BatSubstring.html#TYPEt">t</a></code></pre> <pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> string</code></pre><div class="info "> <code class="code">string sus</code> is the string s<code class="code">i..i+n-1</code> represented by sus = (s, i, n).<br> </div> <pre><span id="VALof_string"><span class="keyword">val</span> of_string</span> : <code class="type">string -> <a href="BatSubstring.html#TYPEt">t</a></code></pre> <pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> char -> <a href="BatSubstring.html#TYPEt">t</a></code></pre> <pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">int -> <a href="BatSubstring.html#TYPEt">t</a></code></pre> <pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> -> bool</code></pre><div class="info "> Substring equality<br> <b>Since</b> 2.1<br> </div> <pre><span id="VALof_input"><span class="keyword">val</span> of_input</span> : <code class="type"><a href="BatIO.html#TYPEinput">BatIO.input</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre> <pre><span id="VALsubstring"><span class="keyword">val</span> substring</span> : <code class="type">string -> int -> int -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">substring s o l</code> returns a substring with base-string <code class="code">s</code>, offset <code class="code">o</code> and length <code class="code">l</code>. Arguments are checked for validity <p> <code class="code">substring s i n</code> creates the substring <code class="code">(s, i, n)</code>, consisting of the substring of s with length n starting at i.<br> <b>Raises</b> <code>Inavlid_argument</code> if <code class="code">i<0</code> or <code class="code">n<0</code> or <code class="code">i+n > size s</code>. Equivalent to <code class="code">extract s i (<span class="constructor">Some</span> n)</code>.<br> </div> <pre><span id="VALunsafe_substring"><span class="keyword">val</span> unsafe_substring</span> : <code class="type">string -> int -> int -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">unsafe_substring</code> behaves like <code class="code">substring</code>, but does not perform any sanity check on the position and length.<br> </div> <pre><span id="VALextract"><span class="keyword">val</span> extract</span> : <code class="type">string -> int -> int option -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">extract s i <span class="constructor">None</span></code> creates the substring (s, i, size s-i) consisting of the tail of s starting at i.<br> <b>Raises</b><ul><li><code>Invalid_argument</code> if <code class="code">i<0</code> or <code class="code">i > size s</code>. <p> <code class="code">extract s i (<span class="constructor">Some</span> n)</code> creates the substring (s, i, n), consisting of the substring of s with length n starting at i.</li> <li><code>Invalid_argument</code> if <code class="code">i<0</code> or <code class="code">n<0</code> or <code class="code">i+n > size s</code>.</li> </ul> </div> <pre><span id="VALall"><span class="keyword">val</span> all</span> : <code class="type">string -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">all s</code> is the substring <code class="code">(s, 0, size s)</code>.<br> </div> <pre><span id="VALbase"><span class="keyword">val</span> base</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> string * int * int</code></pre><div class="info "> <code class="code">base sus</code> is the concrete triple <code class="code">(s, i, n)</code>, where <code class="code">psus = (s, i, n)</code>.<br> </div> <pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">isEmpty (s, i, n)</code> true if the substring is empty (that is, <code class="code">n = 0</code>).<br> </div> <pre><span id="VALgetc"><span class="keyword">val</span> getc</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> (char * <a href="BatSubstring.html#TYPEt">t</a>) option</code></pre><div class="info "> <code class="code">getc sus</code> returns <code class="code"><span class="constructor">Some</span>(c, rst)</code> where <code class="code">c</code> is the first character and <code class="code">rst</code> the remainder of <code class="code">sus</code>, if <code class="code">sus</code> is non-empty; otherwise returns <code class="code"><span class="constructor">None</span></code>.<br> </div> <pre><span id="VALfirst"><span class="keyword">val</span> first</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char option</code></pre><div class="info "> <code class="code">first sus</code> returns <code class="code"><span class="constructor">Some</span> c</code> where <code class="code">c</code> is the first character in <code class="code">sus</code>, if <code class="code">sus</code> is non-empty; otherwise returns <code class="code"><span class="constructor">None</span></code>.<br> </div> <pre><span id="VALtriml"><span class="keyword">val</span> triml</span> : <code class="type">int -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">triml k sus</code> returns sus less its leftmost k characters; or the empty string at the end of sus if it has less than k characters.<br> <b>Raises</b> <code>Invalid_argument</code> if <code class="code">k < 0</code>, even in the partial application <code class="code">triml k</code>.<br> </div> <pre><span id="VALtrimr"><span class="keyword">val</span> trimr</span> : <code class="type">int -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">trimr k sus</code> returns sus less its rightmost k characters; or the empty string at the beginning of sus if it has less than k characters.<br> <b>Raises</b> <code>Invalid_argument</code> if <code class="code">k < 0</code>, even in the partial application <code class="code">trimr k</code>.<br> </div> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int -> char</code></pre><div class="info "> <code class="code">sub sus k</code> returns the k'th character of the substring; that is, s(i+k) where sus = (s, i, n).<br> <b>Raises</b> <code>Invalid_argument</code> if <code class="code">k<0</code> or <code class="code">k>=n</code>.<br> </div> <pre><span id="VALsize"><span class="keyword">val</span> size</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int</code></pre><div class="info "> <code class="code">size (s, i, n)</code> returns the size of the substring, that is, <code class="code">n</code>.<br> </div> <pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int</code></pre><div class="info "> Equivalent to <a href="BatSubstring.html#VALsize"><code class="code"><span class="constructor">BatSubstring</span>.size</code></a>.<br> </div> <pre><span id="VALslice"><span class="keyword">val</span> slice</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int -> int option -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">slice sus i' <span class="constructor">None</span></code> returns the substring <code class="code">(s, i+i', n-i')</code>, where <code class="code">sus = (s, i, n)</code>.<br> <b>Raises</b><ul><li><code>Invalid_argument</code> if <code class="code">i' < 0</code> or <code class="code">i' > n</code>. <p> <code class="code">slice sus i' (<span class="constructor">Some</span> n')</code> returns the substring <code class="code">(s, i+i', n')</code>, where <code class="code">sus</code> = <code class="code">(s, i, n)</code>.</li> <li><code>Invalid_argument</code> if <code class="code">i' < 0</code> or <code class="code">n' < 0</code> or <code class="code">i'+n' >= n</code>.</li> </ul> </div> <pre><span id="VALconcat"><span class="keyword">val</span> concat</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> list -> string</code></pre><div class="info "> <code class="code">concat suss</code> returns a string consisting of the concatenation of the substrings. Equivalent to <code class="code"><span class="constructor">String</span>.concat (<span class="constructor">List</span>.map to_string suss)</code>.<br> </div> <pre><span id="VALexplode"><span class="keyword">val</span> explode</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char list</code></pre><div class="info "> <code class="code">explode sus</code> returns the list of characters of sus, that is, <code class="code">s(i), s(i+1), ..., s(i+n-1)</code> where <code class="code">sus = (s, i, n)</code>. Equivalent to <code class="code"><span class="constructor">String</span>.explode (to_string ss)</code>.<br> </div> <pre><span id="VALis_prefix"><span class="keyword">val</span> is_prefix</span> : <code class="type">string -> <a href="BatSubstring.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">is_prefix s1 s2</code> is true if <code class="code">s1</code> is a prefix of <code class="code">s2</code>. That is, if there exists a string <code class="code">t</code> such that string <code class="code">s1 ^ t = to_string s2</code>.<br> </div> <pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> -> int</code></pre><div class="info "> <code class="code">compare sus1 sus2</code> performs lexicographic comparison, using the standard ordering Char.compare on the characters.p Equivalent to, but more efficient than, <code class="code"><span class="constructor">String</span>.compare (to_string sus1) (to_string sus2)</code>.<br> </div> <pre><span id="VALindex"><span class="keyword">val</span> index</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char -> int</code></pre><div class="info "> <code class="code">index sus c</code> returns the index of the first occurence of <code class="code">c</code> in <code class="code">sus</code> or<br> <b>Raises</b> <code>Not_found</code> otherwise.<br> </div> <pre><span id="VALindex_from"><span class="keyword">val</span> index_from</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int -> char -> int</code></pre><div class="info "> <code class="code">index_from sus i c</code> returns the index of the first occurence of <code class="code">c</code> in <code class="code">sus</code> after the index <code class="code">i</code> or<br> <b>Raises</b><ul><li><code>Not_found</code> otherwise. If <code class="code">i</code> is beyond the range of <code class="code">sus</code>,</li> <li><code>Invalid_argument.</code> It is equivalent to <code class="code">i + index (triml i sus) c</code>.</li> </ul> </div> <pre><span id="VALrindex"><span class="keyword">val</span> rindex</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char -> int</code></pre><div class="info "> <code class="code">rindex sus c</code> returns the index of the last occurence of <code class="code">c</code> in <code class="code">sus</code> or<br> <b>Raises</b> <code>Not_found</code> otherwise.<br> </div> <pre><span id="VALrindex_from"><span class="keyword">val</span> rindex_from</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> int -> char -> int</code></pre><div class="info "> <code class="code">index_from sus i c</code> returns the index of the last occurence of <code class="code">c</code> in <code class="code">sus</code> before the index <code class="code">i</code> or<br> <b>Raises</b><ul><li><code>Not_found</code> otherwise. If <code class="code">i</code> is beyond the range of <code class="code">sus</code>,</li> <li><code>Invalid_argument.</code> It is equivalent to <code class="code">rindex (trimr i sus) c</code>.</li> </ul> </div> <pre><span id="VALcontains"><span class="keyword">val</span> contains</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char -> bool</code></pre><div class="info "> <code class="code">contains s c</code> tests if character <code class="code">c</code> appears in the substring <code class="code">s</code>.<br> <b>Since</b> 2.1<br> </div> <pre><span id="VALdropl"><span class="keyword">val</span> dropl</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">dropl p sus</code> drops the longest prefix (left substring) of <code class="code">sus</code> all of whose characters satisfy predicate <code class="code">p</code>. If all characters do, it returns the empty substring <code class="code">(s, i+n, 0)</code> where <code class="code">sus = (s, i, n)</code>.<br> </div> <pre><span id="VALdropr"><span class="keyword">val</span> dropr</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">dropr p sus</code> drops the longest suffix (right substring) of sus all of whose characters satisfy predicate <code class="code">p</code>. If all characters do, it returns the empty substring <code class="code">(s, i, 0)</code> where <code class="code">sus = (s, i, n)</code>.<br> </div> <pre><span id="VALtakel"><span class="keyword">val</span> takel</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">takel p sus</code> returns the longest prefix (left substring) of <code class="code">sus</code> all of whose characters satisfy predicate <code class="code">p</code>. That is, if the left-most character does not satisfy p, returns the empty <code class="code">(s, i, 0)</code> where <code class="code">sus = (s, i, n)</code>.<br> </div> <pre><span id="VALtaker"><span class="keyword">val</span> taker</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">taker p sus</code> returns the longest suffix (right substring) of <code class="code">sus</code> all of whose characters satisfy predicate <code class="code">p</code>. That is, if the right-most character satisfies <code class="code">p</code>, returns the empty <code class="code">(s, i+n, 0)</code> where <code class="code">sus = (s, i, n)</code>. <p> Let <code class="code">p</code> be a predicate and xxxxfyyyyfzzzz a string where all characters in xxxx and zzzz satisfy <code class="code">p</code>, and f a character not satisfying <code class="code">p</code>. Then <p> sus = xxxxfyyyyfzzzz sus = xxxxzzzz ------------------------------------------------------ dropl p sus = fyyyyfzzzz dropr p sus = xxxxfyyyyf takel p sus = xxxx xxxxzzzz taker p sus = zzzz xxxxzzzz <p> It also holds that <code class="code">concat (takel p sus) (dropl p sus) = string sus</code> <code class="code">concat (dropr p sus) (taker p sus) = string sus</code><br> </div> <pre><span id="VALsplitl"><span class="keyword">val</span> splitl</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> * <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">splitl p sus</code> splits <code class="code">sus</code> into a pair <code class="code">(sus1, sus2)</code> of substrings where <code class="code">sus1</code> is the longest prefix (left substring) all of whose characters satisfy <code class="code">p</code>, and <code class="code">sus2</code> is the rest. That is, <code class="code">sus2</code> begins with the leftmost character not satisfying <code class="code">p</code>. Disregarding sideeffects, we have: <code class="code">splitl p sus = (takel p sus, dropl p sus)</code>.<br> </div> <pre><span id="VALsplitr"><span class="keyword">val</span> splitr</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> * <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">splitr p sus</code> splits <code class="code">sus</code> into a pair <code class="code">(sus1, sus2)</code> of substrings where <code class="code">sus2</code> is the longest suffix (right substring) all of whose characters satisfy <code class="code">p</code>, and <code class="code">sus1</code> is the rest. That is, <code class="code">sus1</code> ends with the rightmost character not satisfying <code class="code">p</code>. Disregarding sideeffects, we have: <code class="code">splitr p sus = (dropr p sus, taker p sus)</code><br> </div> <pre><span id="VALsplit_at"><span class="keyword">val</span> split_at</span> : <code class="type">int -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> * <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">split_at sus k</code> returns the pair <code class="code">(sus1, sus2)</code> of substrings, where <code class="code">sus1</code> contains the first <code class="code">k</code> characters of <code class="code">sus</code>, and <code class="code">sus2</code> contains the rest.<br> <b>Raises</b> <code>Invalid_argument</code> if <code class="code">k < 0</code> or <code class="code">k > size sus</code>.<br> </div> <pre><span id="VALspan"><span class="keyword">val</span> span</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">span sus1 sus2</code> returns a substring spanning from the start of <code class="code">sus1</code> to the end of <code class="code">sus2</code>, provided this is well-defined: <code class="code">sus1</code> and <code class="code">sus2</code> must have the same underlying string, and the start of <code class="code">sus1</code> must not be to the right of the end of <code class="code">sus2</code>; otherwise<br> <b>Raises</b> <code>Invalid_argument.</code> More precisely, if <code class="code">base sus1 = (s,i,n)</code> and <code class="code">base sus2 = (s',i',n')</code> and <code class="code">s = s'</code> and <code class="code">i <= i'+n'</code>, then <code class="code">base (span sus1 sus2) = (s, i, i'+n'-i)</code>. This may be used to compute <code class="code">span</code>, <code class="code">union</code>, and <code class="code">intersection</code>.<br> </div> <pre><span id="VALtranslate"><span class="keyword">val</span> translate</span> : <code class="type">(char -> char) -> <a href="BatSubstring.html#TYPEt">t</a> -> string</code></pre><div class="info "> <code class="code">translate f sus</code> applies <code class="code">f</code> to every character of <code class="code">sus</code>, from left to right, and returns the concatenation of the results. Equivalent to <code class="code"><span class="constructor">String</span>.of_list (<span class="constructor">List</span>.map f (explode sus))</code>.<br> </div> <pre><span id="VALtokens"><span class="keyword">val</span> tokens</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre><div class="info "> <code class="code">tokens p sus</code> returns the list of tokens in <code class="code">sus</code>, from left to right, where a token is a non-empty maximal substring of <code class="code">sus</code> not containing any delimiter, and a delimiter is a character satisfying <code class="code">p</code>.<br> </div> <pre><span id="VALfields"><span class="keyword">val</span> fields</span> : <code class="type">(char -> bool) -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre><div class="info "> <code class="code">fields p sus</code> returns the list of fields in <code class="code">sus</code>, from left to right, where a field is a (possibly empty) maximal substring of <code class="code">sus</code> not containing any delimiter, and a delimiter is a character satisfying <code class="code">p</code>. <p> Two tokens may be separated by more than one delimiter, whereas two fields are separated by exactly one delimiter. If the only delimiter is the character <code class="code"><span class="string">'|'</span></code>, then "abc||def" contains two tokens: "abc" and "def" "abc||def" contains three fields: "abc" and "" and "def"<br> </div> <pre><span id="VALfold_left"><span class="keyword">val</span> fold_left</span> : <code class="type">('a -> char -> 'a) -> 'a -> <a href="BatSubstring.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> <code class="code">foldl f e sus</code> folds <code class="code">f</code> over <code class="code">sus</code> from left to right. That is, evaluates <code class="code">f s.[i+n-1] (f ... (f s.[i+1] (f s.[i] e)) ...)</code> tail-recursively, where <code class="code">sus = (s, i, n)</code>. Equivalent to <code class="code"><span class="constructor">List</span>.fold_left f e (explode sus)</code>.<br> </div> <pre><span id="VALfold_right"><span class="keyword">val</span> fold_right</span> : <code class="type">(char -> 'a -> 'a) -> <a href="BatSubstring.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">foldr f e sus</code> folds <code class="code">f</code> over <code class="code">sus</code> from right to left. That is, evaluates <code class="code">f s.[i] (f s.[i+1] (f ... (f s.[i+n-1] e) ...))</code> tail-recursively, where <code class="code">sus = (s, i, n)</code>. Equivalent to <code class="code"><span class="constructor">List</span>.fold_right f e (explode sus)</code>.<br> </div> <pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(char -> unit) -> <a href="BatSubstring.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">iter f sus</code> applies <code class="code">f</code> to all characters of <code class="code">sus</code>, from left to right. Equivalent to <code class="code"><span class="constructor">List</span>.iter f (explode sus)</code>.<br> </div> <pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type">(int -> char -> unit) -> <a href="BatSubstring.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Same as <a href="BatSubstring.html#VALiter"><code class="code"><span class="constructor">BatSubstring</span>.iter</code></a>, but the function is applied to the index of the element as first argument (counting from 0), and the character itself as second argument.<br> <b>Since</b> 2.1<br> </div> <pre><span id="VALtrim"><span class="keyword">val</span> trim</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a></code></pre><div class="info "> removes whitespace from left and right ends of input<br> </div> <pre><span id="VALsplit_on_char"><span class="keyword">val</span> split_on_char</span> : <code class="type">char -> <a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre><div class="info "> <code class="code">split_on_char c ss</code> returns substrings of input <code class="code">ss</code> as divided by <code class="code">c</code><br> </div> <pre><span id="VALsplit_on_pipe"><span class="keyword">val</span> split_on_pipe</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre> <pre><span id="VALsplit_on_dot"><span class="keyword">val</span> split_on_dot</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre> <pre><span id="VALsplit_on_comma"><span class="keyword">val</span> split_on_comma</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre> <pre><span id="VALsplit_on_slash"><span class="keyword">val</span> split_on_slash</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> <a href="BatSubstring.html#TYPEt">t</a> list</code></pre> <pre><span id="VALenum"><span class="keyword">val</span> enum</span> : <code class="type"><a href="BatSubstring.html#TYPEt">t</a> -> char <a href="BatEnum.html#TYPEt">BatEnum.t</a></code></pre><div class="info "> <code class="code">enum ss</code> returns an enumeration of the characters represented by ss. It does no copying so beweare of mutating the original string.<br> <b>Since</b> 2.1<br> </div> <pre><span id="VALprint"><span class="keyword">val</span> print</span> : <code class="type">'a <a href="BatIO.html#TYPEoutput">BatIO.output</a> -> <a href="BatSubstring.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">print oc ss</code> prints <code class="code">ss</code> to the output channel <code class="code">oc</code><br> </div> </body></html>