12345678910111213141516171819202122232425262728293031323334353637383940414243444546(* This file is free software, part of containers. See file "license" for more details. *)(** {1 Tuple Functions} *)type('a,'b)t='a*'bletmakexy=x,yletmap_fstf(x,y)=fx,yletmap_sndf(x,y)=x,fyletmapfg(x,y)=fx,gyletmap_samef(x,y)=fx,fyletmap2fg(a,b)(x,y)=fax,gbyletmap_same2f(a,b)(x,y)=fax,fbyletfst_mapf(x,_)=fxletsnd_mapf(_,x)=fxletiterf(x,y)=fxyletswap(x,y)=y,xlet(<<<)=map_fstlet(>>>)=map_sndlet(***)=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?(pp_start=fun_()->())?(pp_stop=fun_()->())?(pp_sep=funout()->Format.fprintfout",@ ")papbout(x,y)=pp_startout();paoutx;pp_sepout();pbouty;pp_stopout()