aux 0 l
;;
+let list_mapi_acc f a l =
+ let rec aux k a res = function
+ | [] -> a, List.rev res
+ | h::tl -> let a,h = f h k a in aux (k+1) a (h::res) tl
+ in
+ aux 0 a [] l
+;;
+
let list_index p =
let rec aux n =
function
val flatten_map: ('a -> 'b list) -> 'a list -> 'b list
val list_last: 'a list -> 'a
val list_mapi: ('a -> int -> 'b) -> 'a list -> 'b list
+val list_mapi_acc:
+ ('a -> int -> 'acc -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list
(* Finds the zero based index of the first element that satisfies a predicate*)
val list_index: ('a -> bool) -> 'a list -> (int * 'a) option
val sharing_map: ('a -> 'a) -> 'a list -> 'a list