1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3<head> 4<link rel="stylesheet" href="style.css" type="text/css"> 5<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> 6<meta name="viewport" content="width=device-width, initial-scale=1"> 7<link rel="Start" href="index.html"> 8<link rel="Up" href="Set.html"> 9<link title="Index of types" rel=Appendix href="index_types.html"> 10<link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> 11<link title="Index of values" rel=Appendix href="index_values.html"> 12<link title="Index of modules" rel=Appendix href="index_modules.html"> 13<link title="Index of module types" rel=Appendix href="index_module_types.html"> 14<link title="Arg" rel="Chapter" href="Arg.html"> 15<link title="Arg_helper" rel="Chapter" href="Arg_helper.html"> 16<link title="Arith_status" rel="Chapter" href="Arith_status.html"> 17<link title="Array" rel="Chapter" href="Array.html"> 18<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html"> 19<link title="Ast_helper" rel="Chapter" href="Ast_helper.html"> 20<link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html"> 21<link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html"> 22<link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html"> 23<link title="Asttypes" rel="Chapter" href="Asttypes.html"> 24<link title="Attr_helper" rel="Chapter" href="Attr_helper.html"> 25<link title="Big_int" rel="Chapter" href="Big_int.html"> 26<link title="Bigarray" rel="Chapter" href="Bigarray.html"> 27<link title="Buffer" rel="Chapter" href="Buffer.html"> 28<link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html"> 29<link title="Bytes" rel="Chapter" href="Bytes.html"> 30<link title="BytesLabels" rel="Chapter" href="BytesLabels.html"> 31<link title="Callback" rel="Chapter" href="Callback.html"> 32<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html"> 33<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html"> 34<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html"> 35<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html"> 36<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html"> 37<link title="Ccomp" rel="Chapter" href="Ccomp.html"> 38<link title="Char" rel="Chapter" href="Char.html"> 39<link title="Clflags" rel="Chapter" href="Clflags.html"> 40<link title="Complex" rel="Chapter" href="Complex.html"> 41<link title="Condition" rel="Chapter" href="Condition.html"> 42<link title="Config" rel="Chapter" href="Config.html"> 43<link title="Consistbl" rel="Chapter" href="Consistbl.html"> 44<link title="Depend" rel="Chapter" href="Depend.html"> 45<link title="Digest" rel="Chapter" href="Digest.html"> 46<link title="Docstrings" rel="Chapter" href="Docstrings.html"> 47<link title="Dynlink" rel="Chapter" href="Dynlink.html"> 48<link title="Ephemeron" rel="Chapter" href="Ephemeron.html"> 49<link title="Event" rel="Chapter" href="Event.html"> 50<link title="Filename" rel="Chapter" href="Filename.html"> 51<link title="Format" rel="Chapter" href="Format.html"> 52<link title="Gc" rel="Chapter" href="Gc.html"> 53<link title="Genlex" rel="Chapter" href="Genlex.html"> 54<link title="Graphics" rel="Chapter" href="Graphics.html"> 55<link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html"> 56<link title="Hashtbl" rel="Chapter" href="Hashtbl.html"> 57<link title="Identifiable" rel="Chapter" href="Identifiable.html"> 58<link title="Int32" rel="Chapter" href="Int32.html"> 59<link title="Int64" rel="Chapter" href="Int64.html"> 60<link title="Lazy" rel="Chapter" href="Lazy.html"> 61<link title="Lexer" rel="Chapter" href="Lexer.html"> 62<link title="Lexing" rel="Chapter" href="Lexing.html"> 63<link title="List" rel="Chapter" href="List.html"> 64<link title="ListLabels" rel="Chapter" href="ListLabels.html"> 65<link title="Location" rel="Chapter" href="Location.html"> 66<link title="Longident" rel="Chapter" href="Longident.html"> 67<link title="Map" rel="Chapter" href="Map.html"> 68<link title="Marshal" rel="Chapter" href="Marshal.html"> 69<link title="Misc" rel="Chapter" href="Misc.html"> 70<link title="MoreLabels" rel="Chapter" href="MoreLabels.html"> 71<link title="Mutex" rel="Chapter" href="Mutex.html"> 72<link title="Nativeint" rel="Chapter" href="Nativeint.html"> 73<link title="Num" rel="Chapter" href="Num.html"> 74<link title="Numbers" rel="Chapter" href="Numbers.html"> 75<link title="Obj" rel="Chapter" href="Obj.html"> 76<link title="Oo" rel="Chapter" href="Oo.html"> 77<link title="Parse" rel="Chapter" href="Parse.html"> 78<link title="Parser" rel="Chapter" href="Parser.html"> 79<link title="Parsetree" rel="Chapter" href="Parsetree.html"> 80<link title="Parsing" rel="Chapter" href="Parsing.html"> 81<link title="Pervasives" rel="Chapter" href="Pervasives.html"> 82<link title="Pprintast" rel="Chapter" href="Pprintast.html"> 83<link title="Printast" rel="Chapter" href="Printast.html"> 84<link title="Printexc" rel="Chapter" href="Printexc.html"> 85<link title="Printf" rel="Chapter" href="Printf.html"> 86<link title="Queue" rel="Chapter" href="Queue.html"> 87<link title="Random" rel="Chapter" href="Random.html"> 88<link title="Ratio" rel="Chapter" href="Ratio.html"> 89<link title="Scanf" rel="Chapter" href="Scanf.html"> 90<link title="Set" rel="Chapter" href="Set.html"> 91<link title="Sort" rel="Chapter" href="Sort.html"> 92<link title="Spacetime" rel="Chapter" href="Spacetime.html"> 93<link title="Stack" rel="Chapter" href="Stack.html"> 94<link title="StdLabels" rel="Chapter" href="StdLabels.html"> 95<link title="Str" rel="Chapter" href="Str.html"> 96<link title="Stream" rel="Chapter" href="Stream.html"> 97<link title="String" rel="Chapter" href="String.html"> 98<link title="StringLabels" rel="Chapter" href="StringLabels.html"> 99<link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html"> 100<link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html"> 101<link title="Sys" rel="Chapter" href="Sys.html"> 102<link title="Targetint" rel="Chapter" href="Targetint.html"> 103<link title="Tbl" rel="Chapter" href="Tbl.html"> 104<link title="Terminfo" rel="Chapter" href="Terminfo.html"> 105<link title="Thread" rel="Chapter" href="Thread.html"> 106<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html"> 107<link title="Timings" rel="Chapter" href="Timings.html"> 108<link title="Uchar" rel="Chapter" href="Uchar.html"> 109<link title="Unix" rel="Chapter" href="Unix.html"> 110<link title="UnixLabels" rel="Chapter" href="UnixLabels.html"> 111<link title="Warnings" rel="Chapter" href="Warnings.html"> 112<link title="Weak" rel="Chapter" href="Weak.html"><title>Set.Make</title> 113</head> 114<body> 115<div class="navbar"> <a class="up" href="Set.html" title="Set">Up</a> 116 </div> 117<h1>Functor <a href="type_Set.Make.html">Set.Make</a></h1> 118 119<pre><span class="keyword">module</span> Make: <div class="sig_block"><code class="code"><span class="keyword">functor</span> (</code><code class="code"><span class="constructor">Ord</span></code><code class="code"> : </code><code class="type"><a href="Set.OrderedType.html">OrderedType</a></code><code class="code">) <span class="keywordsign">-></span> </code><code class="type"><a href="Set.S.html">S</a></code><code class="type"> with type elt = Ord.t</code></div></pre><div class="info module top"> 120Functor building an implementation of the set structure 121 given a totally ordered type.<br> 122</div> 123<table border="0" cellpadding="3" width="100%"> 124<tr> 125<td align="left" valign="top" width="1%%"><b>Parameters: </b></td> 126<td> 127<table class="paramstable"> 128<tr> 129<td align="center" valign="top" width="15%"> 130<code>Ord</code></td> 131<td align="center" valign="top">:</td> 132<td><code class="type"><a href="Set.OrderedType.html">OrderedType</a></code> 133</table> 134</td> 135</tr> 136</table> 137<hr width="100%"> 138 139<pre><span id="TYPEelt"><span class="keyword">type</span> <code class="type"></code>elt</span> </pre> 140<div class="info "> 141The type of the set elements.<br> 142</div> 143 144 145<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre> 146<div class="info "> 147The type of sets.<br> 148</div> 149 150 151<pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 152The empty set.<br> 153</div> 154 155<pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 156Test whether a set is empty or not.<br> 157</div> 158 159<pre><span id="VALmem"><span class="keyword">val</span> mem</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 160<code class="code">mem x s</code> tests whether <code class="code">x</code> belongs to the set <code class="code">s</code>.<br> 161</div> 162 163<pre><span id="VALadd"><span class="keyword">val</span> add</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 164<code class="code">add x s</code> returns a set containing all elements of <code class="code">s</code>, 165 plus <code class="code">x</code>. If <code class="code">x</code> was already in <code class="code">s</code>, <code class="code">s</code> is returned unchanged 166 (the result of the function is then physically equal to <code class="code">s</code>).<br> 167<b>Before 4.03 </b> Physical equality was not ensured.<br> 168</div> 169 170<pre><span id="VALsingleton"><span class="keyword">val</span> singleton</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 171<code class="code">singleton x</code> returns the one-element set containing only <code class="code">x</code>.<br> 172</div> 173 174<pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 175<code class="code">remove x s</code> returns a set containing all elements of <code class="code">s</code>, 176 except <code class="code">x</code>. If <code class="code">x</code> was not in <code class="code">s</code>, <code class="code">s</code> is returned unchanged 177 (the result of the function is then physically equal to <code class="code">s</code>).<br> 178<b>Before 4.03 </b> Physical equality was not ensured.<br> 179</div> 180 181<pre><span id="VALunion"><span class="keyword">val</span> union</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 182Set union.<br> 183</div> 184 185<pre><span id="VALinter"><span class="keyword">val</span> inter</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 186Set intersection.<br> 187</div> 188 189<pre><span id="VALdiff"><span class="keyword">val</span> diff</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 190Set difference.<br> 191</div> 192 193<pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> int</code></pre><div class="info "> 194Total ordering between sets. Can be used as the ordering function 195 for doing sets of sets.<br> 196</div> 197 198<pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 199<code class="code">equal s1 s2</code> tests whether the sets <code class="code">s1</code> and <code class="code">s2</code> are 200 equal, that is, contain equal elements.<br> 201</div> 202 203<pre><span id="VALsubset"><span class="keyword">val</span> subset</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 204<code class="code">subset s1 s2</code> tests whether the set <code class="code">s1</code> is a subset of 205 the set <code class="code">s2</code>.<br> 206</div> 207 208<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> unit) -> <a href="Set.S.html#TYPEt">t</a> -> unit</code></pre><div class="info "> 209<code class="code">iter f s</code> applies <code class="code">f</code> in turn to all elements of <code class="code">s</code>. 210 The elements of <code class="code">s</code> are presented to <code class="code">f</code> in increasing order 211 with respect to the ordering over the type of the elements.<br> 212</div> 213 214<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEelt">elt</a>) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 215<code class="code">map f s</code> is the set whose elements are <code class="code">f a0</code>,<code class="code">f a1</code>... <code class="code">f<br> 216 aN</code>, where <code class="code">a0</code>,<code class="code">a1</code>...<code class="code">aN</code> are the elements of <code class="code">s</code>. 217<p> 218 219 The elements are passed to <code class="code">f</code> in increasing order 220 with respect to the ordering over the type of the elements. 221<p> 222 223 If no element of <code class="code">s</code> is changed by <code class="code">f</code>, <code class="code">s</code> is returned 224 unchanged. (If each output of <code class="code">f</code> is physically equal to its 225 input, the returned set is physically equal to <code class="code">s</code>.)<br> 226<b>Since</b> 4.04.0<br> 227</div> 228 229<pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> 'a -> 'a) -> <a href="Set.S.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> 230<code class="code">fold f s a</code> computes <code class="code">(f xN ... (f x2 (f x1 a))...)</code>, 231 where <code class="code">x1 ... xN</code> are the elements of <code class="code">s</code>, in increasing order.<br> 232</div> 233 234<pre><span id="VALfor_all"><span class="keyword">val</span> for_all</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 235<code class="code">for_all p s</code> checks if all elements of the set 236 satisfy the predicate <code class="code">p</code>.<br> 237</div> 238 239<pre><span id="VALexists"><span class="keyword">val</span> exists</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> bool</code></pre><div class="info "> 240<code class="code">exists p s</code> checks if at least one element of 241 the set satisfies the predicate <code class="code">p</code>.<br> 242</div> 243 244<pre><span id="VALfilter"><span class="keyword">val</span> filter</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 245<code class="code">filter p s</code> returns the set of all elements in <code class="code">s</code> 246 that satisfy predicate <code class="code">p</code>. If <code class="code">p</code> satisfies every element in <code class="code">s</code>, 247 <code class="code">s</code> is returned unchanged (the result of the function is then 248 physically equal to <code class="code">s</code>).<br> 249<b>Before 4.03 </b> Physical equality was not ensured.<br> 250</div> 251 252<pre><span id="VALpartition"><span class="keyword">val</span> partition</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> * <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 253<code class="code">partition p s</code> returns a pair of sets <code class="code">(s1, s2)</code>, where 254 <code class="code">s1</code> is the set of all the elements of <code class="code">s</code> that satisfy the 255 predicate <code class="code">p</code>, and <code class="code">s2</code> is the set of all the elements of 256 <code class="code">s</code> that do not satisfy <code class="code">p</code>.<br> 257</div> 258 259<pre><span id="VALcardinal"><span class="keyword">val</span> cardinal</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> int</code></pre><div class="info "> 260Return the number of elements of a set.<br> 261</div> 262 263<pre><span id="VALelements"><span class="keyword">val</span> elements</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> list</code></pre><div class="info "> 264Return the list of all elements of the given set. 265 The returned list is sorted in increasing order with respect 266 to the ordering <code class="code"><span class="constructor">Ord</span>.compare</code>, where <code class="code"><span class="constructor">Ord</span></code> is the argument 267 given to <a href="Set.Make.html"><code class="code"><span class="constructor">Set</span>.<span class="constructor">Make</span></code></a>.<br> 268</div> 269 270<pre><span id="VALmin_elt"><span class="keyword">val</span> min_elt</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 271Return the smallest element of the given set 272 (with respect to the <code class="code"><span class="constructor">Ord</span>.compare</code> ordering), or raise 273 <code class="code"><span class="constructor">Not_found</span></code> if the set is empty.<br> 274</div> 275 276<pre><span id="VALmin_elt_opt"><span class="keyword">val</span> min_elt_opt</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 277Return the smallest element of the given set 278 (with respect to the <code class="code"><span class="constructor">Ord</span>.compare</code> ordering), or <code class="code"><span class="constructor">None</span></code> 279 if the set is empty.<br> 280<b>Since</b> 4.05<br> 281</div> 282 283<pre><span id="VALmax_elt"><span class="keyword">val</span> max_elt</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 284Same as <a href="Set.S.html#VALmin_elt"><code class="code"><span class="constructor">Set</span>.<span class="constructor">S</span>.min_elt</code></a>, but returns the largest element of the 285 given set.<br> 286</div> 287 288<pre><span id="VALmax_elt_opt"><span class="keyword">val</span> max_elt_opt</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 289Same as <a href="Set.S.html#VALmin_elt_opt"><code class="code"><span class="constructor">Set</span>.<span class="constructor">S</span>.min_elt_opt</code></a>, but returns the largest element of the 290 given set.<br> 291<b>Since</b> 4.05<br> 292</div> 293 294<pre><span id="VALchoose"><span class="keyword">val</span> choose</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 295Return one element of the given set, or raise <code class="code"><span class="constructor">Not_found</span></code> if 296 the set is empty. Which element is chosen is unspecified, 297 but equal elements will be chosen for equal sets.<br> 298</div> 299 300<pre><span id="VALchoose_opt"><span class="keyword">val</span> choose_opt</span> : <code class="type"><a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 301Return one element of the given set, or <code class="code"><span class="constructor">None</span></code> if 302 the set is empty. Which element is chosen is unspecified, 303 but equal elements will be chosen for equal sets.<br> 304<b>Since</b> 4.05<br> 305</div> 306 307<pre><span id="VALsplit"><span class="keyword">val</span> split</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEt">t</a> * bool * <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 308<code class="code">split x s</code> returns a triple <code class="code">(l, present, r)</code>, where 309 <code class="code">l</code> is the set of elements of <code class="code">s</code> that are 310 strictly less than <code class="code">x</code>; 311 <code class="code">r</code> is the set of elements of <code class="code">s</code> that are 312 strictly greater than <code class="code">x</code>; 313 <code class="code">present</code> is <code class="code"><span class="keyword">false</span></code> if <code class="code">s</code> contains no element equal to <code class="code">x</code>, 314 or <code class="code"><span class="keyword">true</span></code> if <code class="code">s</code> contains an element equal to <code class="code">x</code>.<br> 315</div> 316 317<pre><span id="VALfind"><span class="keyword">val</span> find</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 318<code class="code">find x s</code> returns the element of <code class="code">s</code> equal to <code class="code">x</code> (according 319 to <code class="code"><span class="constructor">Ord</span>.compare</code>), or raise <code class="code"><span class="constructor">Not_found</span></code> if no such element 320 exists.<br> 321<b>Since</b> 4.01.0<br> 322</div> 323 324<pre><span id="VALfind_opt"><span class="keyword">val</span> find_opt</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 325<code class="code">find_opt x s</code> returns the element of <code class="code">s</code> equal to <code class="code">x</code> (according 326 to <code class="code"><span class="constructor">Ord</span>.compare</code>), or <code class="code"><span class="constructor">None</span></code> if no such element 327 exists.<br> 328<b>Since</b> 4.05<br> 329</div> 330 331<pre><span id="VALfind_first"><span class="keyword">val</span> find_first</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 332<code class="code">find_first f s</code>, where <code class="code">f</code> is a monotonically increasing function, 333 returns the lowest element <code class="code">e</code> of <code class="code">s</code> such that <code class="code">f e</code>, 334 or raises <code class="code"><span class="constructor">Not_found</span></code> if no such element exists. 335<p> 336 337 For example, <code class="code">find_first (<span class="keyword">fun</span> e <span class="keywordsign">-></span> <span class="constructor">Ord</span>.compare e x >= 0) s</code> will return 338 the first element <code class="code">e</code> of <code class="code">s</code> where <code class="code"><span class="constructor">Ord</span>.compare e x >= 0</code> (intuitively: 339 <code class="code">e >= x</code>), or raise <code class="code"><span class="constructor">Not_found</span></code> if <code class="code">x</code> is greater than any element of 340 <code class="code">s</code>.<br> 341<b>Since</b> 4.05<br> 342</div> 343 344<pre><span id="VALfind_first_opt"><span class="keyword">val</span> find_first_opt</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 345<code class="code">find_first_opt f s</code>, where <code class="code">f</code> is a monotonically increasing function, 346 returns an option containing the lowest element <code class="code">e</code> of <code class="code">s</code> such that 347 <code class="code">f e</code>, or <code class="code"><span class="constructor">None</span></code> if no such element exists.<br> 348<b>Since</b> 4.05<br> 349</div> 350 351<pre><span id="VALfind_last"><span class="keyword">val</span> find_last</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a></code></pre><div class="info "> 352<code class="code">find_last f s</code>, where <code class="code">f</code> is a monotonically decreasing function, 353 returns the highest element <code class="code">e</code> of <code class="code">s</code> such that <code class="code">f e</code>, 354 or raises <code class="code"><span class="constructor">Not_found</span></code> if no such element exists.<br> 355<b>Since</b> 4.05<br> 356</div> 357 358<pre><span id="VALfind_last_opt"><span class="keyword">val</span> find_last_opt</span> : <code class="type">(<a href="Set.S.html#TYPEelt">elt</a> -> bool) -> <a href="Set.S.html#TYPEt">t</a> -> <a href="Set.S.html#TYPEelt">elt</a> option</code></pre><div class="info "> 359<code class="code">find_last_opt f s</code>, where <code class="code">f</code> is a monotonically decreasing function, 360 returns an option containing the highest element <code class="code">e</code> of <code class="code">s</code> such that 361 <code class="code">f e</code>, or <code class="code"><span class="constructor">None</span></code> if no such element exists.<br> 362<b>Since</b> 4.05<br> 363</div> 364 365<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type"><a href="Set.S.html#TYPEelt">elt</a> list -> <a href="Set.S.html#TYPEt">t</a></code></pre><div class="info "> 366<code class="code">of_list l</code> creates a set from a list of elements. 367 This is usually more efficient than folding <code class="code">add</code> over the list, 368 except perhaps for lists with many duplicated elements.<br> 369<b>Since</b> 4.02.0<br> 370</div> 371</body></html>