let rev_mapi l ~f ~i = let rec loop i acc = function | [] -> acc | h :: t -> loop (i + 1) (f i h :: acc) t in loop i [] l