123456789101112131415161718192021222324252627282930open!Importletconstc_=cexternalignore:_->unit="%ignore"(* this has the same behavior as [Caml.ignore] *)letnonfx=not(fx)letforeverf=letrecforever()=f();forever()intryforever()withe->eexternalid:'a->'a="%identity"external(|>):'a->('a->'b)->'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)