mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
2 lines
No EOL
31 KiB
HTML
2 lines
No EOL
31 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCArray_sliceLabels (containers.CCArray_sliceLabels)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../index.html">containers</a> » CCArray_sliceLabels</nav><h1>Module <code>CCArray_sliceLabels</code></h1><h2 id="array-slice"><a href="#array-slice" class="anchor"></a>Array Slice</h2><nav class="toc"><ul><li><a href="#io">IO</a></li></ul></nav></header><dl><dt class="spec type" id="type-sequence"><a href="#type-sequence" class="anchor"></a><code><span class="keyword">type </span>'a sequence</code><code><span class="keyword"> = </span>(<span class="type-var">'a</span> <span>-></span> unit) <span>-></span> unit</code></dt><dt class="spec type" id="type-klist"><a href="#type-klist" class="anchor"></a><code><span class="keyword">type </span>'a klist</code><code><span class="keyword"> = </span>unit <span>-></span> [ `Nil<span class="keyword"> | </span>`Cons of <span class="type-var">'a</span><span class="keyword"> * </span><span class="type-var">'a</span> <a href="index.html#type-klist">klist</a> ]</code></dt><dt class="spec type" id="type-gen"><a href="#type-gen" class="anchor"></a><code><span class="keyword">type </span>'a gen</code><code><span class="keyword"> = </span>unit <span>-></span> <span class="type-var">'a</span> option</code></dt><dt class="spec type" id="type-equal"><a href="#type-equal" class="anchor"></a><code><span class="keyword">type </span>'a equal</code><code><span class="keyword"> = </span><span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> bool</code></dt><dt class="spec type" id="type-ord"><a href="#type-ord" class="anchor"></a><code><span class="keyword">type </span>'a ord</code><code><span class="keyword"> = </span><span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> int</code></dt><dt class="spec type" id="type-random_gen"><a href="#type-random_gen" class="anchor"></a><code><span class="keyword">type </span>'a random_gen</code><code><span class="keyword"> = </span>Random.State.t <span>-></span> <span class="type-var">'a</span></code></dt><dt class="spec type" id="type-printer"><a href="#type-printer" class="anchor"></a><code><span class="keyword">type </span>'a printer</code><code><span class="keyword"> = </span>Format.formatter <span>-></span> <span class="type-var">'a</span> <span>-></span> unit</code></dt><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type </span>'a t</code></dt><dd><p>The type for an array slice, containing elements of type <code>'a</code></p></dd></dl><dl><dt class="spec value" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span class="keyword">val </span>empty : <span class="type-var">'a</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>empty</code> is the empty array slice.</p></dd></dl><dl><dt class="spec value" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span class="keyword">val </span>equal : <span class="type-var">'a</span> <a href="index.html#type-equal">equal</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <a href="index.html#type-equal">equal</a></code></dt><dd><p><code>equal eq as1 as2</code> is <code>true</code> if the lengths of <code>as1</code> and <code>as2</code> are the same and if the corresponding elements test equal using <code>eq</code>.</p></dd></dl><dl><dt class="spec value" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span class="keyword">val </span>compare : <span class="type-var">'a</span> <a href="index.html#type-ord">ord</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <a href="index.html#type-ord">ord</a></code></dt><dd><p><code>compare cmp as1 as2</code> compares the two slices <code>as1</code> and <code>as2</code> using the comparison function <code>cmp</code>, element by element.</p></dd></dl><dl><dt class="spec value" id="val-get"><a href="#val-get" class="anchor"></a><code><span class="keyword">val </span>get : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> <span class="type-var">'a</span></code></dt><dd><p><code>get as n</code> returns the element number <code>n</code> of slice <code>as</code>. The first element has number 0. The last element has number <code>length as - 1</code>. You can also write <code>as.(n)</code> instead of <code>get as n</code>.</p><p>Raise <code>Invalid_argument "index out of bounds"</code> if <code>n</code> is outside the range 0 to <code>(length as - 1)</code>.</p></dd></dl><dl><dt class="spec value" id="val-get_safe"><a href="#val-get_safe" class="anchor"></a><code><span class="keyword">val </span>get_safe : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> <span class="type-var">'a</span> option</code></dt><dd><p><code>get_safe as i</code> returns <code>Some as.(i)</code> if <code>i</code> is a valid index.</p><dl><dt>since</dt><dd>0.18</dd></dl></dd></dl><dl><dt class="spec value" id="val-make"><a href="#val-make" class="anchor"></a><code><span class="keyword">val </span>make : <span class="type-var">'a</span> array <span>-></span> int <span>-></span> len:int <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>make a i ~len</code> creates a slice from given offset <code>i</code> and length <code>len</code> of the given array <code>a</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if the slice isn't valid.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-of_slice"><a href="#val-of_slice" class="anchor"></a><code><span class="keyword">val </span>of_slice : (<span class="type-var">'a</span> array<span class="keyword"> * </span>int<span class="keyword"> * </span>int) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>of_slice (a, i, len)</code> makes a slice from a triple <code>(a, i, len)</code> where <code>a</code> is the array, <code>i</code> the offset in <code>a</code>, and <code>len</code> the number of elements of the slice.</p><dl><dt>raises Invalid_argument</dt><dd><p>if the slice isn't valid (See <a href="index.html#val-make"><code>make</code></a>).</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-to_slice"><a href="#val-to_slice" class="anchor"></a><code><span class="keyword">val </span>to_slice : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> array<span class="keyword"> * </span>int<span class="keyword"> * </span>int</code></dt><dd><p><code>to_slice as</code> converts the slice <code>as</code> into a triple <code>(a, i, len)</code> where <code>len</code> is the length of the sub-array of <code>a</code> starting at offset <code>i</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_list"><a href="#val-to_list" class="anchor"></a><code><span class="keyword">val </span>to_list : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> list</code></dt><dd><p><code>to_list as</code> converts the slice <code>as</code> directly to a list.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-full"><a href="#val-full" class="anchor"></a><code><span class="keyword">val </span>full : <span class="type-var">'a</span> array <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>full a</code> creates a slice that covers the full array <code>a</code>.</p></dd></dl><dl><dt class="spec value" id="val-underlying"><a href="#val-underlying" class="anchor"></a><code><span class="keyword">val </span>underlying : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> array</code></dt><dd><p><code>underlying as</code> returns the underlying array (shared). Modifying this array will modify the slice <code>as</code>.</p></dd></dl><dl><dt class="spec value" id="val-copy"><a href="#val-copy" class="anchor"></a><code><span class="keyword">val </span>copy : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> array</code></dt><dd><p><code>copy as</code> copies the slice <code>as</code> into a new array.</p></dd></dl><dl><dt class="spec value" id="val-sub"><a href="#val-sub" class="anchor"></a><code><span class="keyword">val </span>sub : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> int <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>sub as i len</code> builds a new sub-slice that contains the given subrange specified by the index <code>i</code> and the length <code>len</code>.</p></dd></dl><dl><dt class="spec value" id="val-set"><a href="#val-set" class="anchor"></a><code><span class="keyword">val </span>set : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> <span class="type-var">'a</span> <span>-></span> unit</code></dt><dd><p><code>set as n x</code> modifies the slice <code>as</code> in place, replacing element number <code>n</code> with <code>x</code>. You can also write <code>as.(n) <- x</code> instead of <code>set as n x</code>.</p><p>Raise <code>Invalid_argument "index out of bounds"</code> if <code>n</code> is outside the range 0 to <code>length as - 1</code>.</p></dd></dl><dl><dt class="spec value" id="val-length"><a href="#val-length" class="anchor"></a><code><span class="keyword">val </span>length : <span class="type-var">_</span> <a href="index.html#type-t">t</a> <span>-></span> int</code></dt><dd><p><code>length as</code> returns the length (number of elements) of the given slice <code>as</code>.</p></dd></dl><dl><dt class="spec value" id="val-fold"><a href="#val-fold" class="anchor"></a><code><span class="keyword">val </span>fold : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> <span class="type-var">'a</span>) <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span></code></dt><dd><p><code>fold f acc as</code> computes <code>f (... (f (f acc as.(0)) as.(1)) ...) as.(length as - 1)</code>.</p></dd></dl><dl><dt class="spec value" id="val-foldi"><a href="#val-foldi" class="anchor"></a><code><span class="keyword">val </span>foldi : (<span class="type-var">'a</span> <span>-></span> int <span>-></span> <span class="type-var">'b</span> <span>-></span> <span class="type-var">'a</span>) <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span></code></dt><dd><p><code>foldi f acc as</code> is just like <a href="index.html#val-fold"><code>fold</code></a> but it also passes in the index of each element as the second argument to the folded function <code>f</code>.</p></dd></dl><dl><dt class="spec value" id="val-fold_while"><a href="#val-fold_while" class="anchor"></a><code><span class="keyword">val </span>fold_while : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> <span class="type-var">'a</span><span class="keyword"> * </span>[ `Stop<span class="keyword"> | </span>`Continue ]) <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span></code></dt><dd><p><code>fold_while f acc as</code> folds left on slice <code>as</code> until a stop condition via <code>('a, `Stop)</code> is indicated by the accumulator.</p><dl><dt>since</dt><dd>0.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span class="keyword">val </span>iter : (<span class="type-var">'a</span> <span>-></span> unit) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>iter f as</code> applies function <code>f</code> in turn to all elements of <code>as</code>. It is equivalent to <code>f as.(0); f as.(1); ...; f as.(length as - 1); ()</code>.</p></dd></dl><dl><dt class="spec value" id="val-iteri"><a href="#val-iteri" class="anchor"></a><code><span class="keyword">val </span>iteri : (int <span>-></span> <span class="type-var">'a</span> <span>-></span> unit) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>iteri f as</code> is like <a href="index.html#val-iter"><code>iter</code></a>, but the function <code>f</code> is applied with the index of the element as first argument, and the element itself as second argument.</p></dd></dl><dl><dt class="spec value" id="val-blit"><a href="#val-blit" class="anchor"></a><code><span class="keyword">val </span>blit : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int <span>-></span> int <span>-></span> unit</code></dt><dd><p><code>blit as1 o1 as2 o2 len</code> copies <code>len</code> elements from slice <code>as1</code>, starting at element number <code>o1</code>, to slice <code>as2</code>, starting at element number <code>o2</code>. It works correctly even if <code>as1</code> and <code>as2</code> are the same slice, and the source and destination chunks overlap.</p><p>Raise <code>Invalid_argument "CCArray_slice.blit"</code> if <code>o1</code> and <code>len</code> do not designate a valid subarray of <code>as1</code>, or if <code>o2</code> and <code>len</code> do not designate a valid subarray of <code>as2</code>.</p></dd></dl><dl><dt class="spec value" id="val-reverse_in_place"><a href="#val-reverse_in_place" class="anchor"></a><code><span class="keyword">val </span>reverse_in_place : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>reverse_in_place as</code> reverses the slice <code>as</code> in place.</p></dd></dl><dl><dt class="spec value" id="val-sorted"><a href="#val-sorted" class="anchor"></a><code><span class="keyword">val </span>sorted : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> int) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> array</code></dt><dd><p><code>sorted cmp as</code> makes a copy of <code>as</code> and sorts it with <code>cmp</code>.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-sort_indices"><a href="#val-sort_indices" class="anchor"></a><code><span class="keyword">val </span>sort_indices : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> int) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int array</code></dt><dd><p><code>sort_indices cmp as</code> returns a new array <code>b</code>, with the same length as <code>as</code>, such that <code>b.(i)</code> is the index at which the <code>i</code>-th element of <code>sorted cmp as</code> appears in <code>as</code>. <code>as</code> is not modified.</p><p>In other words, <code>map (fun i -> as.(i)) (sort_indices cmp as) = sorted cmp as</code>. <code>sort_indices</code> yields the inverse permutation of <a href="index.html#val-sort_ranking"><code>sort_ranking</code></a>.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-sort_ranking"><a href="#val-sort_ranking" class="anchor"></a><code><span class="keyword">val </span>sort_ranking : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> int) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int array</code></dt><dd><p><code>sort_ranking cmp as</code> returns a new array <code>b</code>, with the same length as <code>as</code>, such that <code>b.(i)</code> is the index at which the <code>i</code>-th element of <code>as</code> appears in <code>sorted cmp as</code>. <code>as</code> is not modified.</p><p>In other words, <code>map (fun i -> (sorted cmp as).(i)) (sort_ranking cmp as) = as</code>. <code>sort_ranking</code> yields the inverse permutation of <a href="index.html#val-sort_indices"><code>sort_indices</code></a>.</p><p>In the absence of duplicate elements in <code>as</code>, we also have <code>lookup_exn as.(i) (sorted as) = (sorted_ranking as).(i)</code>.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-find"><a href="#val-find" class="anchor"></a><code><span class="keyword">val </span>find : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> option) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> option</code></dt><dd><p><code>find f as</code> returns <code>Some y</code> if there is an element <code>x</code> such that <code>f x = Some y</code>. Otherwise returns <code>None</code>.</p></dd></dl><dl><dt class="spec value" id="val-findi"><a href="#val-findi" class="anchor"></a><code><span class="keyword">val </span>findi : (int <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> option) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> option</code></dt><dd><p><code>findi f as</code> is like <a href="index.html#val-find"><code>find</code></a>, but the index of the element is also passed to the predicate function <code>f</code>.</p><dl><dt>since</dt><dd>0.3.4</dd></dl></dd></dl><dl><dt class="spec value" id="val-find_idx"><a href="#val-find_idx" class="anchor"></a><code><span class="keyword">val </span>find_idx : (<span class="type-var">'a</span> <span>-></span> bool) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> (int<span class="keyword"> * </span><span class="type-var">'a</span>) option</code></dt><dd><p><code>find_idx p as</code> returns <code>Some (i,x)</code> where <code>x</code> is the <code>i</code>-th element of <code>as</code>, and <code>p x</code> holds. Otherwise returns <code>None</code>.</p><dl><dt>since</dt><dd>0.3.4</dd></dl></dd></dl><dl><dt class="spec value" id="val-lookup"><a href="#val-lookup" class="anchor"></a><code><span class="keyword">val </span>lookup : cmp:<span class="type-var">'a</span> <a href="index.html#type-ord">ord</a> <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int option</code></dt><dd><p><code>lookup ~cmp x as</code> lookups the index <code>i</code> of some key <code>x</code> in the slice <code>as</code>, provided <code>as</code> is sorted using <code>cmp</code>.</p><dl><dt>returns</dt><dd><p><code>None</code> if the key <code>x</code> is not present, or <code>Some i</code> (<code>i</code> the index of the key) otherwise.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-lookup_exn"><a href="#val-lookup_exn" class="anchor"></a><code><span class="keyword">val </span>lookup_exn : cmp:<span class="type-var">'a</span> <a href="index.html#type-ord">ord</a> <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> int</code></dt><dd><p><code>lookup_exn ~cmp x as</code> is like <a href="index.html#val-lookup"><code>lookup</code></a>, but</p><dl><dt>raises Not_found</dt><dd><p>if the key <code>x</code> is not present.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-bsearch"><a href="#val-bsearch" class="anchor"></a><code><span class="keyword">val </span>bsearch : cmp:(<span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> int) <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> [ `All_lower<span class="keyword"> | </span>`All_bigger<span class="keyword"> | </span>`Just_after of int<span class="keyword"> | </span>`Empty<span class="keyword"> | </span>`At of int ]</code></dt><dd><p><code>bsearch ~cmp x as</code> finds the index of the object <code>x</code> in the slice <code>as</code>, provided <code>as</code> is <b>sorted</b> using <code>cmp</code>. If the slice is not sorted, the result is not specified (may raise Invalid_argument).</p><p>Complexity: <code>O(log n)</code> where n is the length of the slice <code>as</code> (dichotomic search).</p><dl><dt>returns</dt><dd><ul><li><code>`At i</code> if <code>cmp as.(i) x = 0</code> (for some i).</li><li><code>`All_lower</code> if all elements of <code>as</code> are lower than <code>x</code>.</li><li><code>`All_bigger</code> if all elements of <code>as</code> are bigger than <code>x</code>.</li><li><code>`Just_after i</code> if <code>as.(i) < x < as.(i+1)</code>.</li><li><code>`Empty</code> if the slice <code>as</code> is empty.</li></ul></dd></dl><dl><dt>raises Invalid_argument</dt><dd><p>if the slice is found to be unsorted w.r.t <code>cmp</code>.</p></dd></dl><dl><dt>since</dt><dd>0.13</dd></dl></dd></dl><dl><dt class="spec value" id="val-for_all"><a href="#val-for_all" class="anchor"></a><code><span class="keyword">val </span>for_all : (<span class="type-var">'a</span> <span>-></span> bool) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dd><p><code>for_all p [|as1; ...; asn|]</code> checks if all elements of the slice satisfy the predicate <code>p</code>. That is, it returns <code>(p as1) && (p as2) && ... && (p asn)</code>.</p></dd></dl><dl><dt class="spec value" id="val-for_all2"><a href="#val-for_all2" class="anchor"></a><code><span class="keyword">val </span>for_all2 : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> bool) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dd><p><code>for_all2 p [|as1; ...; asn|] [|bs1; ...; bsn|]</code> is <code>true</code> if each pair of elements <code>asi bsi</code> satisfies the predicate <code>p</code>. That is, it returns <code>(p as1 bs1) && (p as2 bs2) && ... && (p asn bsn)</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if slices have distinct lengths. Allow different types.</p></dd></dl><dl><dt>since</dt><dd>0.20</dd></dl></dd></dl><dl><dt class="spec value" id="val-exists"><a href="#val-exists" class="anchor"></a><code><span class="keyword">val </span>exists : (<span class="type-var">'a</span> <span>-></span> bool) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dd><p><code>exists p [|as1; ...; asn|]</code> is <code>true</code> if at least one element of the slice satisfies the predicate <code>p</code>. That is, it returns <code>(p as1) || (p as2) || ... || (p asn)</code>.</p></dd></dl><dl><dt class="spec value" id="val-exists2"><a href="#val-exists2" class="anchor"></a><code><span class="keyword">val </span>exists2 : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> bool) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dd><p><code>exists2 p [|as1; ...; asn|] [|bs1; ...; bsn|]</code> is <code>true</code> if any pair of elements <code>asi bsi</code> satisfies the predicate <code>p</code>. That is, it returns <code>(p as1 bs1) || (p as2 bs2) || ... || (p asn bsn)</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if slices have distinct lengths. Allow different types.</p></dd></dl><dl><dt>since</dt><dd>0.20</dd></dl></dd></dl><dl><dt class="spec value" id="val-fold2"><a href="#val-fold2" class="anchor"></a><code><span class="keyword">val </span>fold2 : (<span class="type-var">'acc</span> <span>-></span> <span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> <span class="type-var">'acc</span>) <span>-></span> <span class="type-var">'acc</span> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'acc</span></code></dt><dd><p><code>fold2 f acc as bs</code> fold on two slices <code>as</code> and <code>bs</code> stepwise. It computes <code>f (... (f acc as1 bs1)...) asn bsn</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if slices have distinct lengths.</p></dd></dl><dl><dt>since</dt><dd>0.20</dd></dl></dd></dl><dl><dt class="spec value" id="val-iter2"><a href="#val-iter2" class="anchor"></a><code><span class="keyword">val </span>iter2 : (<span class="type-var">'a</span> <span>-></span> <span class="type-var">'b</span> <span>-></span> unit) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'b</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>iter2 f as bs</code> iterates on the two slices <code>as</code> and <code>bs</code> stepwise. It is equivalent to <code>f as0 bs0; ...; f as.(length as - 1) bs.(length bs - 1); ()</code>.</p><dl><dt>raises Invalid_argument</dt><dd><p>if slices have distinct lengths.</p></dd></dl><dl><dt>since</dt><dd>0.20</dd></dl></dd></dl><dl><dt class="spec value" id="val-shuffle"><a href="#val-shuffle" class="anchor"></a><code><span class="keyword">val </span>shuffle : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>shuffle as</code> randomly shuffles the slice <code>as</code>, in place.</p></dd></dl><dl><dt class="spec value" id="val-shuffle_with"><a href="#val-shuffle_with" class="anchor"></a><code><span class="keyword">val </span>shuffle_with : Random.State.t <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>shuffle_with rs as</code> randomly shuffles the slice <code>as</code> (like <a href="index.html#val-shuffle"><code>shuffle</code></a>) but a specialized random state <code>rs</code> is used to control the random numbers being produced during shuffling (for reproducibility).</p></dd></dl><dl><dt class="spec value" id="val-random_choose"><a href="#val-random_choose" class="anchor"></a><code><span class="keyword">val </span>random_choose : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-random_gen">random_gen</a></code></dt><dd><p><code>random_choose as rs</code> randomly chooses an element of <code>as</code>.</p><dl><dt>raises Not_found</dt><dd><p>if the array/slice is empty.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-to_seq"><a href="#val-to_seq" class="anchor"></a><code><span class="keyword">val </span>to_seq : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-sequence">sequence</a></code></dt><dd><p><code>to_seq as</code> returns a <code>sequence</code> of the elements of a slice <code>as</code>. The input slice <code>as</code> is shared with the sequence and modification of it will result in modification of the sequence.</p></dd></dl><dl><dt class="spec value" id="val-to_gen"><a href="#val-to_gen" class="anchor"></a><code><span class="keyword">val </span>to_gen : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-gen">gen</a></code></dt><dd><p><code>to_gen as</code> returns a <code>gen</code> of the elements of a slice <code>as</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_klist"><a href="#val-to_klist" class="anchor"></a><code><span class="keyword">val </span>to_klist : <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-klist">klist</a></code></dt><dd><p><code>to_klist as</code> returns a <code>klist</code> of the elements of a slice <code>as</code>.</p></dd></dl><section><header><h2 id="io"><a href="#io" class="anchor"></a>IO</h2></header><dl><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val </span>pp : ?⁠sep:string <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-printer">printer</a> <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <a href="index.html#type-printer">printer</a></code></dt><dd><p><code>pp ~sep pp_item ppf as</code> formats the slice <code>as</code> on <code>ppf</code>. Each element is formatted with <code>pp_item</code> and elements are separated by <code>sep</code> (defaults to ", ").</p></dd></dl><dl><dt class="spec value" id="val-pp_i"><a href="#val-pp_i" class="anchor"></a><code><span class="keyword">val </span>pp_i : ?⁠sep:string <span>-></span> (int <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-printer">printer</a>) <span>-></span> <span class="type-var">'a</span> <a href="index.html#type-t">t</a> <a href="index.html#type-printer">printer</a></code></dt><dd><p><code>pp_i ~sep pp_item ppf as</code> prints the slice <code>as</code> on <code>ppf</code>. The printing function <code>pp_item</code> is giving both index and element. Elements are separated by <code>sep</code> (defaults to ", ").</p></dd></dl></section></div></body></html> |