KKostya
7/25/2018 - 1:42 PM

foldi.ml

let rec foldi ~base ?(i=0) f l =
  match l with
  | [] -> base
  | x :: tail -> f i x ( foldi f ~base ~i:(i+1) tail )