ocaml-containers/dev/containers/CCOrd/index.html
2019-11-08 11:28:29 -06:00

6 lines
No EOL
7.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCOrd (containers.CCOrd)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc %%VERSION%%"/><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> &#x00BB; CCOrd</nav><h1>Module <code>CCOrd</code></h1><h2 id="comparisons"><a href="#comparisons" class="anchor"></a>Comparisons</h2><nav class="toc"><ul><li><a href="#lexicographic-combination">Lexicographic Combination</a></li></ul></nav></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> <span>'a t</span></code><code> = <span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> int</code></dt><dd><p>Comparison (total ordering) between two elements, that returns an int.</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><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Polymorphic &quot;magic&quot; comparison.</p></dd></dl><dl><dt class="spec value" id="val-opp"><a href="#val-opp" class="anchor"></a><code><span class="keyword">val</span> opp : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Opposite order.</p></dd></dl><dl><dt class="spec value" id="val-equiv"><a href="#val-equiv" class="anchor"></a><code><span class="keyword">val</span> equiv : int <span>&#45;&gt;</span> int <span>&#45;&gt;</span> bool</code></dt><dd><p>Returns <code>true</code> iff the two comparison results are the same.</p></dd></dl><dl><dt class="spec value" id="val-int"><a href="#val-int" class="anchor"></a><code><span class="keyword">val</span> int : <span>int <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-string"><a href="#val-string" class="anchor"></a><code><span class="keyword">val</span> string : <span>string <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span class="keyword">val</span> bool : <span>bool <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-float"><a href="#val-float" class="anchor"></a><code><span class="keyword">val</span> float : <span>float <a href="index.html#type-t">t</a></span></code></dt></dl><section><header><h3 id="lexicographic-combination"><a href="#lexicographic-combination" class="anchor"></a>Lexicographic Combination</h3></header><dl><dt class="spec value" id="val-(&lt;?&gt;)"><a href="#val-(&lt;?&gt;)" class="anchor"></a><code><span class="keyword">val</span> (&lt;?&gt;) : int <span>&#45;&gt;</span> <span>(<span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> * <span class="type-var">'a</span> * <span class="type-var">'a</span>)</span> <span>&#45;&gt;</span> int</code></dt><dd><p><code>c1 &lt;?&gt; (ord, x, y)</code> returns the same as <code>c1</code> if <code>c1</code> is not <code>0</code>; otherwise it uses <code>ord</code> to compare the two values <code>x</code> and <code>y</code>, of type <code>'a</code>.</p><p>Example:</p><pre><code class="ml">CCInt.compare 1 3
&lt;?&gt; (String.compare, &quot;a&quot;, &quot;b&quot;)
&lt;?&gt; (CCBool.compare, true, false)</code></pre><p>Same example, using only CCOrd::</p><pre><code class="ml">CCOrd.(int 1 3
&lt;?&gt; (string, &quot;a&quot;, &quot;b&quot;)
&lt;?&gt; (bool, true, false))</code></pre></dd></dl><dl><dt class="spec value" id="val-option"><a href="#val-option" class="anchor"></a><code><span class="keyword">val</span> option : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> option</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Comparison of optional values. <code>None</code> is smaller than any <code>Some _</code>.</p><dl><dt>since</dt><dd>0.15</dd></dl></dd></dl><dl><dt class="spec value" id="val-pair"><a href="#val-pair" class="anchor"></a><code><span class="keyword">val</span> pair : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-triple"><a href="#val-triple" class="anchor"></a><code><span class="keyword">val</span> triple : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'c</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span>)</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-list"><a href="#val-list" class="anchor"></a><code><span class="keyword">val</span> list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> list</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Lexicographic combination on lists.</p></dd></dl><dl><dt class="spec value" id="val-array"><a href="#val-array" class="anchor"></a><code><span class="keyword">val</span> array : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> array</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-map"><a href="#val-map" class="anchor"></a><code><span class="keyword">val</span> map : <span>(<span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'b</span>)</span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p><code>map f ord</code> is the comparison function that, given objects <code>x</code> and <code>y</code>, projects <code>x</code> and <code>y</code> using <code>f</code> (e.g. using a record field) and then compares those projections with <code>ord</code>. Example: <code>map fst CCInt.compare</code> compares values of type <code>(int * 'a)</code> by their first component.</p></dd></dl><dl><dt class="spec value" id="val-(&gt;|=)"><a href="#val-(&gt;|=)" class="anchor"></a><code><span class="keyword">val</span> (&gt;|=) : <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span>(<span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'b</span>)</span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Infix equivalent of <a href="index.html#val-map"><code>map</code></a>.</p></dd></dl><div class="spec module" id="module-Infix"><a href="#module-Infix" class="anchor"></a><code><span class="keyword">module</span> <a href="Infix/index.html">Infix</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></div></section></div></body></html>