let
foldi t ~f ~init =
snd (fold t ~init:(0, init) ~f:(
fun
(i, acc) v
->
(i + 1, f i acc v)))