# FreeBSD Manual Pages

Set.S(3) OCamldoc Set.S(3)NAMESet.S - Output signature of the functor Set.Make.Module typeModule type Set.SDocumentationModule typeS=sigendOutput signature of the functorSet.Make.typeeltThe type of the set elements.typetThe type of sets.valempty:tThe empty set.valis_empty:t->boolTest whether a set is empty or not.valmem:elt->t->boolmemxstests whetherxbelongs to the sets.valadd:elt->t->taddxsreturns a set containing all elements ofs, plusx. Ifxwas already ins,sis returned unchanged (the result of the function is then physically equal tos).Before4.03Physical equality was not ensured.valsingleton:elt->tsingletonxreturns the one-element set containing onlyx.valremove:elt->t->tremovexsreturns a set containing all elements ofs, exceptx. Ifxwas not ins,sis returned unchanged (the result of the function is then physically equal tos).Before4.03Physical equality was not ensured.valunion:t->t->tSet union.valinter:t->t->tSet intersection.valdiff:t->t->tSet difference.valcompare:t->t->intTotal ordering between sets. Can be used as the ordering function for doing sets of sets.valequal:t->t->boolequals1s2tests whether the setss1ands2are equal, that is, con- tain equal elements.valsubset:t->t->boolsubsets1s2tests whether the sets1is a subset of the sets2.valiter:(elt->unit)->t->unititerfsappliesfin turn to all elements ofs. The elements ofsare presented tofin increasing order with respect to the ordering over the type of the elements.valmap:(elt->elt)->t->tmapfsis the set whose elements arefa0,fa1...faN, wherea0,a1...aNare the elements ofs. The elements are passed tofin increasing order with respect to the ordering over the type of the elements. If no element ofsis changed byf,sis returned unchanged. (If each output offis physically equal to its input, the returned set is phys- ically equal tos.)Since4.04.0valfold:(elt->'a->'a)->t->'a->'afoldfsacomputes(fxN...(fx2(fx1a))...), wherex1...xNare the elements ofs, in increasing order.valfor_all:(elt->bool)->t->boolfor_allpschecks if all elements of the set satisfy the predicatep.valexists:(elt->bool)->t->boolexistspschecks if at least one element of the set satisfies the predicatep.valfilter:(elt->bool)->t->tfilterpsreturns the set of all elements insthat satisfy predicatep. Ifpsatisfies every element ins,sis returned unchanged (the result of the function is then physically equal tos).Before4.03Physical equality was not ensured.valpartition:(elt->bool)->t->t*tpartitionpsreturns a pair of sets(s1,s2), wheres1is the set of all the elements ofsthat satisfy the predicatep, ands2is the set of all the elements ofsthat do not satisfyp.valcardinal:t->intReturn the number of elements of a set.valelements:t->eltlistReturn the list of all elements of the given set. The returned list is sorted in increasing order with respect to the orderingOrd.compare, whereOrdis the argument given toSet.Make.valmin_elt:t->eltReturn the smallest element of the given set (with respect to theOrd.compareordering), or raiseNot_foundif the set is empty.valmin_elt_opt:t->eltoptionReturn the smallest element of the given set (with respect to theOrd.compareordering), orNoneif the set is empty.Since4.05valmax_elt:t->eltSame asSet.S.min_elt, but returns the largest element of the given set.valmax_elt_opt:t->eltoptionSame asSet.S.min_elt_opt, but returns the largest element of the given set.Since4.05valchoose:t->eltReturn one element of the given set, or raiseNot_foundif the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.valchoose_opt:t->eltoptionReturn one element of the given set, orNoneif the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.Since4.05valsplit:elt->t->t*bool*tsplitxsreturns a triple(l,present,r), wherelis the set of ele- ments ofsthat are strictly less thanx;ris the set of elements ofsthat are strictly greater thanx;presentisfalseifscontains no element equal tox, ortrueifscontains an element equal tox.valfind:elt->t->eltfindxsreturns the element ofsequal tox(according toOrd.compare), or raiseNot_foundif no such element exists.Since4.01.0valfind_opt:elt->t->eltoptionfind_optxsreturns the element ofsequal tox(according toOrd.com-pare), orNoneif no such element exists.Since4.05valfind_first:(elt->bool)->t->eltfind_firstfs, wherefis a monotonically increasing function, re- turns the lowest elementeofssuch thatfe, or raisesNot_foundif no such element exists. For example,find_first(fune->Ord.compareex>=0)swill return the first elementeofswhereOrd.compareex>=0(intuitively:e>=x), or raiseNot_foundifxis greater than any element ofs.Since4.05valfind_first_opt:(elt->bool)->t->eltoptionfind_first_optfs, wherefis a monotonically increasing function, returns an option containing the lowest elementeofssuch thatfe, orNoneif no such element exists.Since4.05valfind_last:(elt->bool)->t->eltfind_lastfs, wherefis a monotonically decreasing function, returns the highest elementeofssuch thatfe, or raisesNot_foundif no such element exists.Since4.05valfind_last_opt:(elt->bool)->t->eltoptionfind_last_optfs, wherefis a monotonically decreasing function, re- turns an option containing the highest elementeofssuch thatfe, orNoneif no such element exists.Since4.05valof_list:eltlist->tof_listlcreates a set from a list of elements. This is usually more efficient than foldingaddover the list, except perhaps for lists with many duplicated elements.Since4.02.0 2020-08-11 source: Set.S(3)

NAME | Module type | Documentation

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=Set.S&sektion=3o&manpath=FreeBSD+12.2-RELEASE+and+Ports>