12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576moduletypeS=Set_intf.SmoduleMake(Elt:Comparable.S):Swithtypeelt=Elt.t=structmoduleM=MoreLabels.Set.Make(structtypet=Elt.tletcompareab=Ordering.to_int(Elt.compareab)end)includestruct[@@@warning"-32"](* [map] is only available since 4.04 *)letmap~ft=M.elementst|>List.map~f|>M.of_list(* Since 4.05 *)letto_optft=matchftwith|x->Somex|exceptionNot_found->Noneletchoose_opt=to_optM.chooseletmin_elt_opt=to_optM.min_eltletmax_elt_opt=to_optM.max_eltendincludeMletto_list=elementsletmemtx=memxtletaddtx=addxtletremovetx=removextletcompareab=Ordering.of_int(compareab)letis_subsett~of_=subsettof_letitert~f=itert~fletmapt~f=mapt~fletfoldt~init~f=foldt~init~fletfor_allt~f=for_allt~fletexistst~f=existst~fletfiltert~f=filtert~fletpartitiont~f=partitiont~fletmin_elt=min_elt_optletmax_elt=max_elt_optletchoose=choose_optletsplitxt=splittxletunion_mapl~f=List.fold_left~init:emptyl~f:(funaccx->lets=fxinunionaccs)letunion_alll=union_mapl~f:(funx->x)exceptionFoundofeltletfindt~f=matchitert~f:(fune->iffethenraise_notrace(Founde)else())with|()->None|exception(Founde)->Someeletchoose_exnt=matchchoosetwith|Somee->e|None->Exn.code_error"Set.choose_exn"[]endletto_sexpto_listft=Sexp.Encoder.listf(to_listt)