1234567891011121314151617181920(** Tail-recursive replacements for [List] functions that are not tail-recursive
in OCaml 4.14 and can stack-overflow on large inputs.
[List.rev_map] and [List.rev] are both tail-recursive in every OCaml
version, so [map f l = List.rev (List.rev_map f l)] is safe regardless of
list length. *)letmapfl=List.rev(List.rev_mapfl)letfilterfl=List.rev(List.fold_left(funaccx->iffxthenx::accelseacc)[]l)letfilter_mapfl=List.rev(List.fold_left(funaccx->matchfxwith|Somey->y::acc|None->acc)[]l)