123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103includeIndexed_container_intfletwith_return=With_return.with_returnletiteri~foldt~f=ignore(foldt~init:0~f:(funix->fix;i+1):int);;letfoldi~foldt~init~f=leti=ref0infoldt~init~f:(funaccv->letacc=f!iaccvini:=!i+1;acc);;letcounti~foldit~f=foldit~init:0~f:(funina->iffiathenn+1elsen)letexistsi~iteric~f=with_return(funr->iteric~f:(funix->iffixthenr.returntrue);false);;letfor_alli~iteric~f=with_return(funr->iteric~f:(funix->ifnot(fix)thenr.returnfalse);true);;letfind_mapi~iterit~f=with_return(funr->iterit~f:(funix->matchfixwith|None->()|Some_asres->r.returnres);None);;letfindi~iteric~f=with_return(funr->iteric~f:(funix->iffixthenr.return(Some(i,x)));None);;moduleMake_gen(T:sigincludeContainer_intf.Make_gen_argvaliteri:[`Define_using_fold|`Customof('at,'aelt)iteri]valfoldi:[`Define_using_fold|`Customof('at,'aelt,_)foldi]end):Genericwithtype'at:='aT.twithtype'aelt:='aT.elt=structincludeContainer.Make_gen(T)letiteri=matchT.iteriwith|`Customiteri->iteri|`Define_using_fold->funt~f->iteri~foldt~f;;letfoldi=matchT.foldiwith|`Customfoldi->foldi|`Define_using_fold->funt~init~f->foldi~foldt~init~f;;letcountit~f=counti~foldit~fletexistsit~f=existsi~iterit~fletfor_allit~f=for_alli~iterit~fletfind_mapit~f=find_mapi~iterit~fletfindit~f=findi~iterit~fendmoduleMake(T:Make_arg)=structmoduleC=Container.Make(T)(* Not part of [Container.Generic]. *)letmem=C.memincludeMake_gen(structincludeTtype'at='aT.ttype'aelt='aend)endmoduleMake0(T:Make0_arg)=structmoduleC=Container.Make0(T)(* Not part of [Container.Generic]. *)letmem=C.memincludeMake_gen(structincludeTtype'at=T.ttype'aelt=T.Elt.tend)end