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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
|
<!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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Array.html">
<link rel="next" href="Bigarray.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of extensions" rel=Appendix href="index_extensions.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 modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Bool" rel="Chapter" href="Bool.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Bytes" rel="Chapter" href="Bytes.html">
<link title="BytesLabels" rel="Chapter" href="BytesLabels.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html">
<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html">
<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Ephemeron" rel="Chapter" href="Ephemeron.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Float" rel="Chapter" href="Float.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Fun" rel="Chapter" href="Fun.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Int" rel="Chapter" href="Int.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Ocaml_operators" rel="Chapter" href="Ocaml_operators.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Option" rel="Chapter" href="Option.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Result" rel="Chapter" href="Result.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Seq" rel="Chapter" href="Seq.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Spacetime" rel="Chapter" href="Spacetime.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Stdlib" rel="Chapter" href="Stdlib.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Uchar" rel="Chapter" href="Uchar.html">
<link title="Unit" rel="Chapter" href="Unit.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Weak" rel="Chapter" href="Weak.html"><link title="Iterators on two arrays" rel="Section" href="#1_Iteratorsontwoarrays">
<link title="Array scanning" rel="Section" href="#1_Arrayscanning">
<link title="Sorting" rel="Section" href="#1_Sorting">
<link title="Iterators" rel="Section" href="#1_Iterators">
<title>ArrayLabels</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Array.html" title="Array">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Bigarray.html" title="Bigarray">Next</a>
</div>
<h1>Module <a href="type_ArrayLabels.html">ArrayLabels</a></h1>
<pre><span id="MODULEArrayLabels"><span class="keyword">module</span> ArrayLabels</span>: <code class="code"><span class="keyword">sig</span></code> <a href="ArrayLabels.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<div class="info-desc">
<p>Array operations</p>
<p>This module is intended to be used via <a href="StdLabels.html"><code class="code"><span class="constructor">StdLabels</span></code></a> which replaces
<a href="Array.html"><code class="code"><span class="constructor">Array</span></code></a>, <a href="Bytes.html"><code class="code"><span class="constructor">Bytes</span></code></a>, <a href="List.html"><code class="code"><span class="constructor">List</span></code></a> and <a href="String.html"><code class="code"><span class="constructor">String</span></code></a> with their labeled counterparts</p>
<p>For example:</p>
<pre class="codepre"><code class="code"> <span class="keyword">open</span> <span class="constructor">StdLabels</span>
<span class="keyword">let</span> everything = <span class="constructor">Array</span>.create_matrix ~dimx:42 ~dimy:42 42
</code></pre></div>
</div>
<hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> = <code class="type">'a array</code> </pre>
<div class="info ">
<div class="info-desc">
<p>An alias for the type of arrays.</p>
</div>
</div>
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">'a array -> int</code></pre><div class="info ">
<div class="info-desc">
<p>Return the length (number of elements) of the given array.</p>
</div>
</div>
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">'a array -> int -> 'a</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">get a n</code> returns the element number <code class="code">n</code> of array <code class="code">a</code>.
The first element has number 0.
The last element has number <code class="code">length a - 1</code>.
You can also write <code class="code">a.(n)</code> instead of <code class="code">get a n</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">n</code> is outside the range 0 to <code class="code">(length a - 1)</code>.</li>
</ul>
</div>
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">'a array -> int -> 'a -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">set a n x</code> modifies array <code class="code">a</code> in place, replacing
element number <code class="code">n</code> with <code class="code">x</code>.
You can also write <code class="code">a.(n) <- x</code> instead of <code class="code">set a n x</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">n</code> is outside the range 0 to <code class="code">length a - 1</code>.</li>
</ul>
</div>
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> 'a -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">make n x</code> returns a fresh array of length <code class="code">n</code>,
initialized with <code class="code">x</code>.
All the elements of this new array are initially
physically equal to <code class="code">x</code> (in the sense of the <code class="code">==</code> predicate).
Consequently, if <code class="code">x</code> is mutable, it is shared among all elements
of the array, and modifying <code class="code">x</code> through one of the array entries
will modify all other entries at the same time.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">n < 0</code> or <code class="code">n > <span class="constructor">Sys</span>.max_array_length</code>.
If the value of <code class="code">x</code> is a floating-point number, then the maximum
size is only <code class="code"><span class="constructor">Sys</span>.max_array_length / 2</code>.</li>
</ul>
</div>
<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">int -> 'a -> 'a array</code></pre><div class="info ">
<div class="info-deprecated">
<span class="warning">Deprecated.</span><code class="code">create</code> is an alias for <a href="ArrayLabels.html#VALmake"><code class="code"><span class="constructor">ArrayLabels</span>.make</code></a>.</div>
</div>
<pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type">int -> f:(int -> 'a) -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">init n ~f</code> returns a fresh array of length <code class="code">n</code>,
with element number <code class="code">i</code> initialized to the result of <code class="code">f i</code>.
In other terms, <code class="code">init n ~f</code> tabulates the results of <code class="code">f</code>
applied to the integers <code class="code">0</code> to <code class="code">n-1</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">n < 0</code> or <code class="code">n > <span class="constructor">Sys</span>.max_array_length</code>.
If the return type of <code class="code">f</code> is <code class="code">float</code>, then the maximum
size is only <code class="code"><span class="constructor">Sys</span>.max_array_length / 2</code>.</li>
</ul>
</div>
<pre><span id="VALmake_matrix"><span class="keyword">val</span> make_matrix</span> : <code class="type">dimx:int -> dimy:int -> 'a -> 'a array array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">make_matrix ~dimx ~dimy e</code> returns a two-dimensional array
(an array of arrays) with first dimension <code class="code">dimx</code> and
second dimension <code class="code">dimy</code>. All the elements of this new matrix
are initially physically equal to <code class="code">e</code>.
The element (<code class="code">x,y</code>) of a matrix <code class="code">m</code> is accessed
with the notation <code class="code">m.(x).(y)</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">dimx</code> or <code class="code">dimy</code> is negative or
greater than <a href="Sys.html#VALmax_array_length"><code class="code"><span class="constructor">Sys</span>.max_array_length</code></a>.
If the value of <code class="code">e</code> is a floating-point number, then the maximum
size is only <code class="code"><span class="constructor">Sys</span>.max_array_length / 2</code>.</li>
</ul>
</div>
<pre><span id="VALcreate_matrix"><span class="keyword">val</span> create_matrix</span> : <code class="type">dimx:int -> dimy:int -> 'a -> 'a array array</code></pre><div class="info ">
<div class="info-deprecated">
<span class="warning">Deprecated.</span><code class="code">create_matrix</code> is an alias for <a href="ArrayLabels.html#VALmake_matrix"><code class="code"><span class="constructor">ArrayLabels</span>.make_matrix</code></a>.</div>
</div>
<pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type">'a array -> 'a array -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">append v1 v2</code> returns a fresh array containing the
concatenation of the arrays <code class="code">v1</code> and <code class="code">v2</code>.</p>
</div>
</div>
<pre><span id="VALconcat"><span class="keyword">val</span> concat</span> : <code class="type">'a array list -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALappend"><code class="code"><span class="constructor">ArrayLabels</span>.append</code></a>, but concatenates a list of arrays.</p>
</div>
</div>
<pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type">'a array -> pos:int -> len:int -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">sub a ~pos ~len</code> returns a fresh array of length <code class="code">len</code>,
containing the elements number <code class="code">pos</code> to <code class="code">pos + len - 1</code>
of array <code class="code">a</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">pos</code> and <code class="code">len</code> do not
designate a valid subarray of <code class="code">a</code>; that is, if
<code class="code">pos < 0</code>, or <code class="code">len < 0</code>, or <code class="code">pos + len > length a</code>.</li>
</ul>
</div>
<pre><span id="VALcopy"><span class="keyword">val</span> copy</span> : <code class="type">'a array -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">copy a</code> returns a copy of <code class="code">a</code>, that is, a fresh array
containing the same elements as <code class="code">a</code>.</p>
</div>
</div>
<pre><span id="VALfill"><span class="keyword">val</span> fill</span> : <code class="type">'a array -> pos:int -> len:int -> 'a -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">fill a ~pos ~len x</code> modifies the array <code class="code">a</code> in place,
storing <code class="code">x</code> in elements number <code class="code">pos</code> to <code class="code">pos + len - 1</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">pos</code> and <code class="code">len</code> do not
designate a valid subarray of <code class="code">a</code>.</li>
</ul>
</div>
<pre><span id="VALblit"><span class="keyword">val</span> blit</span> : <code class="type">src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">blit ~src ~src_pos ~dst ~dst_pos ~len</code> copies <code class="code">len</code> elements
from array <code class="code">src</code>, starting at element number <code class="code">src_pos</code>, to array <code class="code">dst</code>,
starting at element number <code class="code">dst_pos</code>. It works correctly even if
<code class="code">src</code> and <code class="code">dst</code> are the same array, and the source and
destination chunks overlap.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">src_pos</code> and <code class="code">len</code> do not
designate a valid subarray of <code class="code">src</code>, or if <code class="code">dst_pos</code> and <code class="code">len</code> do not
designate a valid subarray of <code class="code">dst</code>.</li>
</ul>
</div>
<pre><span id="VALto_list"><span class="keyword">val</span> to_list</span> : <code class="type">'a array -> 'a list</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">to_list a</code> returns the list of all the elements of <code class="code">a</code>.</p>
</div>
</div>
<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type">'a list -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">of_list l</code> returns a fresh array containing the elements
of <code class="code">l</code>.</p>
</div>
</div>
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">f:('a -> unit) -> 'a array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">iter ~f a</code> applies function <code class="code">f</code> in turn to all
the elements of <code class="code">a</code>. It is equivalent to
<code class="code">f a.(0); f a.(1); ...; f a.(length a - 1); ()</code>.</p>
</div>
</div>
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">f:('a -> 'b) -> 'a array -> 'b array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">map ~f a</code> applies function <code class="code">f</code> to all the elements of <code class="code">a</code>,
and builds an array with the results returned by <code class="code">f</code>:
<code class="code">[| f a.(0); f a.(1); ...; f a.(length a - 1) |]</code>.</p>
</div>
</div>
<pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type">f:(int -> 'a -> unit) -> 'a array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALiter"><code class="code"><span class="constructor">ArrayLabels</span>.iter</code></a>, but the
function is applied to the index of the element as first argument,
and the element itself as second argument.</p>
</div>
</div>
<pre><span id="VALmapi"><span class="keyword">val</span> mapi</span> : <code class="type">f:(int -> 'a -> 'b) -> 'a array -> 'b array</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALmap"><code class="code"><span class="constructor">ArrayLabels</span>.map</code></a>, but the
function is applied to the index of the element as first argument,
and the element itself as second argument.</p>
</div>
</div>
<pre><span id="VALfold_left"><span class="keyword">val</span> fold_left</span> : <code class="type">f:('a -> 'b -> 'a) -> init:'a -> 'b array -> 'a</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">fold_left ~f ~init a</code> computes
<code class="code">f (... (f (f init a.(0)) a.(1)) ...) a.(n-1)</code>,
where <code class="code">n</code> is the length of the array <code class="code">a</code>.</p>
</div>
</div>
<pre><span id="VALfold_right"><span class="keyword">val</span> fold_right</span> : <code class="type">f:('b -> 'a -> 'a) -> 'b array -> init:'a -> 'a</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">fold_right ~f a ~init</code> computes
<code class="code">f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))</code>,
where <code class="code">n</code> is the length of the array <code class="code">a</code>.</p>
</div>
</div>
<h2 id="1_Iteratorsontwoarrays">Iterators on two arrays</h2>
<pre><span id="VALiter2"><span class="keyword">val</span> iter2</span> : <code class="type">f:('a -> 'b -> unit) -> 'a array -> 'b array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">iter2 ~f a b</code> applies function <code class="code">f</code> to all the elements of <code class="code">a</code>
and <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.05.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if the arrays are not the same size.</li>
</ul>
</div>
<pre><span id="VALmap2"><span class="keyword">val</span> map2</span> : <code class="type">f:('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">map2 ~f a b</code> applies function <code class="code">f</code> to all the elements of <code class="code">a</code>
and <code class="code">b</code>, and builds an array with the results returned by <code class="code">f</code>:
<code class="code">[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.05.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if the arrays are not the same size.</li>
</ul>
</div>
<h2 id="1_Arrayscanning">Array scanning</h2>
<pre><span id="VALexists"><span class="keyword">val</span> exists</span> : <code class="type">f:('a -> bool) -> 'a array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">exists ~f [|a1; ...; an|]</code> checks if at least one element of
the array satisfies the predicate <code class="code">f</code>. That is, it returns
<code class="code">(f a1) <span class="keywordsign">||</span> (f a2) <span class="keywordsign">||</span> ... <span class="keywordsign">||</span> (f an)</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALfor_all"><span class="keyword">val</span> for_all</span> : <code class="type">f:('a -> bool) -> 'a array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">for_all ~f [|a1; ...; an|]</code> checks if all elements
of the array satisfy the predicate <code class="code">f</code>. That is, it returns
<code class="code">(f a1) <span class="keywordsign">&&</span> (f a2) <span class="keywordsign">&&</span> ... <span class="keywordsign">&&</span> (f an)</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALfor_all2"><span class="keyword">val</span> for_all2</span> : <code class="type">f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALfor_all"><code class="code"><span class="constructor">ArrayLabels</span>.for_all</code></a>, but for a two-argument predicate.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.11.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if the two arrays have different lengths.</li>
</ul>
</div>
<pre><span id="VALexists2"><span class="keyword">val</span> exists2</span> : <code class="type">f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALexists"><code class="code"><span class="constructor">ArrayLabels</span>.exists</code></a>, but for a two-argument predicate.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.11.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if the two arrays have different lengths.</li>
</ul>
</div>
<pre><span id="VALmem"><span class="keyword">val</span> mem</span> : <code class="type">'a -> set:'a array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">mem x ~set</code> is true if and only if <code class="code">x</code> is equal
to an element of <code class="code">set</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALmemq"><span class="keyword">val</span> memq</span> : <code class="type">'a -> set:'a array -> bool</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALmem"><code class="code"><span class="constructor">ArrayLabels</span>.mem</code></a>, but uses physical equality
instead of structural equality to compare list elements.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALcreate_float"><span class="keyword">val</span> create_float</span> : <code class="type">int -> float array</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">create_float n</code> returns a fresh float array of length <code class="code">n</code>,
with uninitialized data.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03</li>
</ul>
</div>
<pre><span id="VALmake_float"><span class="keyword">val</span> make_float</span> : <code class="type">int -> float array</code></pre><div class="info ">
<div class="info-deprecated">
<span class="warning">Deprecated.</span><a href="ArrayLabels.html#VALmake_float"><code class="code"><span class="constructor">ArrayLabels</span>.make_float</code></a> is an alias for
<a href="ArrayLabels.html#VALcreate_float"><code class="code"><span class="constructor">ArrayLabels</span>.create_float</code></a>.</div>
</div>
<h2 id="1_Sorting">Sorting</h2>
<pre><span id="VALsort"><span class="keyword">val</span> sort</span> : <code class="type">cmp:('a -> 'a -> int) -> 'a array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Sort an array in increasing order according to a comparison
function. The comparison function must return 0 if its arguments
compare as equal, a positive integer if the first is greater,
and a negative integer if the first is smaller (see below for a
complete specification). For example, <a href="Stdlib.html#VALcompare"><code class="code">compare</code></a> is
a suitable comparison function, provided there are no floating-point
NaN values in the data. After calling <code class="code">sort</code>, the
array is sorted in place in increasing order.
<code class="code">sort</code> is guaranteed to run in constant heap space
and (at most) logarithmic stack space.</p>
<p>The current implementation uses Heap Sort. It runs in constant
stack space.</p>
<p>Specification of the comparison function:
Let <code class="code">a</code> be the array and <code class="code">cmp</code> the comparison function. The following
must be true for all x, y, z in a :</p>
<ul>
<li> <code class="code">cmp x y</code> > 0 if and only if <code class="code">cmp y x</code> < 0</li>
<li> if <code class="code">cmp x y</code> >= 0 and <code class="code">cmp y z</code> >= 0 then <code class="code">cmp x z</code> >= 0</li>
</ul>
<p>When <code class="code">sort</code> returns, <code class="code">a</code> contains the same elements as before,
reordered in such a way that for all i and j valid indices of <code class="code">a</code> :</p>
<ul>
<li> <code class="code">cmp a.(i) a.(j)</code> >= 0 if and only if i >= j</li>
</ul>
</div>
</div>
<pre><span id="VALstable_sort"><span class="keyword">val</span> stable_sort</span> : <code class="type">cmp:('a -> 'a -> int) -> 'a array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALsort"><code class="code"><span class="constructor">ArrayLabels</span>.sort</code></a>, but the sorting algorithm is stable (i.e.
elements that compare equal are kept in their original order) and
not guaranteed to run in constant heap space.</p>
<p>The current implementation uses Merge Sort. It uses <code class="code">n/2</code>
words of heap space, where <code class="code">n</code> is the length of the array.
It is usually faster than the current implementation of <a href="ArrayLabels.html#VALsort"><code class="code"><span class="constructor">ArrayLabels</span>.sort</code></a>.</p>
</div>
</div>
<pre><span id="VALfast_sort"><span class="keyword">val</span> fast_sort</span> : <code class="type">cmp:('a -> 'a -> int) -> 'a array -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <a href="ArrayLabels.html#VALsort"><code class="code"><span class="constructor">ArrayLabels</span>.sort</code></a> or <a href="ArrayLabels.html#VALstable_sort"><code class="code"><span class="constructor">ArrayLabels</span>.stable_sort</code></a>, whichever is faster on typical input.</p>
</div>
</div>
<h2 id="1_Iterators">Iterators</h2>
<pre><span id="VALto_seq"><span class="keyword">val</span> to_seq</span> : <code class="type">'a array -> 'a <a href="Seq.html#TYPEt">Seq.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Iterate on the array, in increasing order</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>
<pre><span id="VALto_seqi"><span class="keyword">val</span> to_seqi</span> : <code class="type">'a array -> (int * 'a) <a href="Seq.html#TYPEt">Seq.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Iterate on the array, in increasing order, yielding indices along elements</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>
<pre><span id="VALof_seq"><span class="keyword">val</span> of_seq</span> : <code class="type">'a <a href="Seq.html#TYPEt">Seq.t</a> -> 'a array</code></pre><div class="info ">
<div class="info-desc">
<p>Create an array from the generator</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>
</body></html>
|