let fold_righti f array init = fst (Array.fold_right (fun a (b,index) -> f index a b, pred index) array (init, Array.length array -1))