File: manual057.html

package info (click to toggle)
ocaml-doc 2.04-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,820 kB
  • ctags: 997
  • sloc: makefile: 38; sh: 12
file content (201 lines) | stat: -rw-r--r-- 8,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!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">
<TITLE>
 Module String: string operations
</TITLE>
</HEAD>
<BODY >
<A HREF="manual056.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual058.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>

<H2>17.27&nbsp;&nbsp; Module <TT>String</TT>: string operations</H2><A NAME="s:String"></A>
<A NAME="@manual460"></A><PRE>
val length : string -&gt; int
</PRE>
<A NAME="@manual461"></A><BLOCKQUOTE>
Return the length (number of characters) of the given string. 
</BLOCKQUOTE>
<PRE>
val get : string -&gt; int -&gt; char
</PRE>
<A NAME="@manual462"></A><BLOCKQUOTE>
<CODE>String.get s n</CODE> returns character number <CODE>n</CODE> in string <CODE>s</CODE>.
The first character is character number 0.
The last character is character number <CODE>String.length s - 1</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>n</CODE> is outside the range
0 to <CODE>(String.length s - 1)</CODE>.
You can also write <CODE>s.[n]</CODE> instead of <CODE>String.get s n</CODE>. 
</BLOCKQUOTE>
<PRE>
val set : string -&gt; int -&gt; char -&gt; unit
</PRE>
<A NAME="@manual463"></A><BLOCKQUOTE>
<CODE>String.set s n c</CODE> modifies string <CODE>s</CODE> in place,
replacing the character number <CODE>n</CODE> by <CODE>c</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>n</CODE> is outside the range
0 to <CODE>(String.length s - 1)</CODE>.
You can also write <CODE>s.[n] &lt;- c</CODE> instead of <CODE>String.set s n c</CODE>. 
</BLOCKQUOTE>
<PRE>
val create : int -&gt; string
</PRE>
<A NAME="@manual464"></A><BLOCKQUOTE>
<CODE>String.create n</CODE> returns a fresh string of length <CODE>n</CODE>.
The string initially contains arbitrary characters.
Raise <CODE>Invalid_argument</CODE> if <CODE>n &lt;= 0</CODE> or <CODE>n &gt; Sys.max_string_length</CODE>.</BLOCKQUOTE>
<PRE>
val make : int -&gt; char -&gt; string
</PRE>
<A NAME="@manual465"></A><BLOCKQUOTE>
<CODE>String.make n c</CODE> returns a fresh string of length <CODE>n</CODE>,
filled with the character <CODE>c</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>n &lt;= 0</CODE> or <CODE>n &gt; Sys.max_string_length</CODE>.</BLOCKQUOTE>
<PRE>
val copy : string -&gt; string
</PRE>
<A NAME="@manual466"></A><BLOCKQUOTE>
Return a copy of the given string. 
</BLOCKQUOTE>
<PRE>
val sub : string -&gt; int -&gt; int -&gt; string
</PRE>
<A NAME="@manual467"></A><BLOCKQUOTE>
<CODE>String.sub s start len</CODE> returns a fresh string of length <CODE>len</CODE>,
containing the characters number <CODE>start</CODE> to <CODE>start + len - 1</CODE>
of string <CODE>s</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>start</CODE> and <CODE>len</CODE> do not
designate a valid substring of <CODE>s</CODE>; that is, if <CODE>start &lt; 0</CODE>,
or <CODE>len &lt; 0</CODE>, or <CODE>start + len &gt; String.length s</CODE>. 
</BLOCKQUOTE>
<PRE>
val fill : string -&gt; int -&gt; int -&gt; char -&gt; unit
</PRE>
<A NAME="@manual468"></A><BLOCKQUOTE>
<CODE>String.fill s start len c</CODE> modifies string <CODE>s</CODE> in place,
replacing the characters number <CODE>start</CODE> to <CODE>start + len - 1</CODE>
by <CODE>c</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>start</CODE> and <CODE>len</CODE> do not
designate a valid substring of <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val blit : string -&gt; int -&gt; string -&gt; int -&gt; int -&gt; unit
</PRE>
<A NAME="@manual469"></A><BLOCKQUOTE>
<CODE>String.blit src srcoff dst dstoff len</CODE> copies <CODE>len</CODE> characters
from string <CODE>src</CODE>, starting at character number <CODE>srcoff</CODE>, to
string <CODE>dst</CODE>, starting at character number <CODE>dstoff</CODE>. It works
correctly even if <CODE>src</CODE> and <CODE>dst</CODE> are the same string,
and the source and destination chunks overlap.
Raise <CODE>Invalid_argument</CODE> if <CODE>srcoff</CODE> and <CODE>len</CODE> do not
designate a valid substring of <CODE>src</CODE>, or if <CODE>dstoff</CODE> and <CODE>len</CODE>
do not designate a valid substring of <CODE>dst</CODE>. 
</BLOCKQUOTE>
<PRE>
val concat : string -&gt; string list -&gt; string
</PRE>
<A NAME="@manual470"></A><BLOCKQUOTE>
<CODE>String.concat sep sl</CODE> catenates the list of strings <CODE>sl</CODE>,
inserting the separator string <CODE>sep</CODE> between each. 
</BLOCKQUOTE>
<PRE>
val escaped: string -&gt; string
</PRE>
<A NAME="@manual471"></A><BLOCKQUOTE>
Return a copy of the argument, with special characters represented
by escape sequences, following the lexical conventions of
Objective Caml. 
</BLOCKQUOTE>
<PRE>
val index: string -&gt; char -&gt; int
</PRE>
<A NAME="@manual472"></A><BLOCKQUOTE>
<CODE>String.index s c</CODE> returns the position of the leftmost
occurrence of character <CODE>c</CODE> in string <CODE>s</CODE>.
Raise <CODE>Not_found</CODE> if <CODE>c</CODE> does not occur in <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val rindex: string -&gt; char -&gt; int
</PRE>
<A NAME="@manual473"></A><BLOCKQUOTE>
<CODE>String.rindex s c</CODE> returns the position of the rightmost
occurrence of character <CODE>c</CODE> in string <CODE>s</CODE>.
Raise <CODE>Not_found</CODE> if <CODE>c</CODE> does not occur in <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val index_from: string -&gt; int -&gt; char -&gt; int
val rindex_from: string -&gt; int -&gt; char -&gt; int
</PRE>
<A NAME="@manual474"></A><A NAME="@manual475"></A><BLOCKQUOTE>
Same as <CODE>String.index</CODE> and <CODE>String.rindex</CODE>, but start
searching at the character position given as second argument.
<CODE>String.index s c</CODE> is equivalent to <CODE>String.index_from s 0 c</CODE>,
and <CODE>String.rindex s c</CODE> to
<CODE>String.rindex_from s (String.length s - 1) c</CODE>. 
</BLOCKQUOTE>
<PRE>
val contains : string -&gt; char -&gt; bool
</PRE>
<A NAME="@manual476"></A><BLOCKQUOTE>
<CODE>String.contains s c</CODE> tests if character <CODE>c</CODE>
appears in the string <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val contains_from : string -&gt; int -&gt; char -&gt; bool
</PRE>
<A NAME="@manual477"></A><BLOCKQUOTE>
<CODE>String.contains_from s start c</CODE> tests if character <CODE>c</CODE>
appears in the substring of <CODE>s</CODE> starting from <CODE>start</CODE> to the end
of <CODE>s</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>start</CODE> is not a valid index of <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val rcontains_from : string -&gt; int -&gt; char -&gt; bool
</PRE>
<A NAME="@manual478"></A><BLOCKQUOTE>
<CODE>String.rcontains_from s stop c</CODE> tests if character <CODE>c</CODE>
appears in the substring of <CODE>s</CODE> starting from the beginning
of <CODE>s</CODE> to index <CODE>stop</CODE>.
Raise <CODE>Invalid_argument</CODE> if <CODE>stop</CODE> is not a valid index of <CODE>s</CODE>. 
</BLOCKQUOTE>
<PRE>
val uppercase: string -&gt; string
</PRE>
<A NAME="@manual479"></A><BLOCKQUOTE>
Return a copy of the argument, with all lowercase letters
translated to uppercase, including accented letters of the ISO
Latin-1 (8859-1) character set. 
</BLOCKQUOTE>
<PRE>
val lowercase: string -&gt; string
</PRE>
<A NAME="@manual480"></A><BLOCKQUOTE>
Return a copy of the argument, with all uppercase letters
translated to lowercase, including accented letters of the ISO
Latin-1 (8859-1) character set. 
</BLOCKQUOTE>
<PRE>
val capitalize: string -&gt; string
</PRE>
<A NAME="@manual481"></A><BLOCKQUOTE>
Return a copy of the argument, with the first letter
set to uppercase. 
</BLOCKQUOTE>
<PRE>
val uncapitalize: string -&gt; string
</PRE>
<A NAME="@manual482"></A><BLOCKQUOTE>
Return a copy of the argument, with the first letter
set to lowercase. 
</BLOCKQUOTE>

<HR>
<A HREF="manual056.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual058.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>