123456789101112131415161718192021222324252627open!Importletconstc_=cexternalignore:(_[@local_opt])->unit="%ignore"(* this has the same behavior as [Stdlib.ignore] *)letnonfx=not(fx)letforeverf=letrecforever()=f();forever()intryforever()with|e->e;;externalid:('a[@local_opt])->('a[@local_opt])="%identity"external(|>):'a->(('a->'b)[@local_opt])->'b="%revapply"(* The typical use case for these functions is to pass in functional arguments and get
functions as a result. *)letcomposefgx=f(gx)letflipfxy=fyxletrecapply_n_times~nfx=ifn<=0thenxelseapply_n_times~n:(n-1)f(fx)