let concat_mapi l ~f = let rec aux cont acc = function | [] -> List.rev acc | hd :: tl -> aux (cont + 1) (rev_append (f cont hd) acc) tl in aux 0 [] l