123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(* This file is free software, part of containers. See file "license" for more details. *)(** {1 Tuple Functions} *)type('a,'b)t=('a*'b)letmakexy=x,yletmap1f(x,y)=fx,yletmap2f(x,y)=x,fyletmapfg(x,y)=fx,gyletmap_samef(x,y)=fx,fyletmap_fstf(x,_)=fxletmap_sndf(_,x)=fxletiterf(x,y)=fxyletswap(x,y)=y,xlet(<<<)=map1let(>>>)=map2let(***)=maplet(&&&)fgx=fx,gxletmergef(x,y)=fxyletfold=mergeletdupx=x,xletdup_mapfx=x,fxletequalfg(x1,y1)(x2,y2)=fx1x2&&gy1y2letcomparefg(x1,y1)(x2,y2)=letc=fx1x2inifc<>0thencelsegy1y2letto_string?(sep=", ")a_to_stringb_to_string(x,y)=Printf.sprintf"%s%s%s"(a_to_stringx)sep(b_to_stringy)type'aprinter=Format.formatter->'a->unitletpp?(sep=", ")papbout(x,y)=Format.fprintfout"%a%s@,%a"paxseppby