List.flatten (List.map f l)
;;
+let list_mapi f l =
+ let rec aux k = function
+ | [] -> []
+ | h::tl -> f h k :: aux (k+1) tl
+ in
+ aux 0 l
+;;
+
let rec list_uniq ?(eq=(=)) = function
| [] -> []
| h::[] -> [h]
val list_findopt: ('a -> 'b option) -> 'a list -> 'b option
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
(** split_nth n l
* @returns two list, the first contains at least n elements, the second the