val list_last: 'a list -> 'a
val list_mapi: ('a -> int -> 'b) -> 'a list -> 'b list
val sharing_map: ('a -> 'a) -> 'a list -> 'a list
+(* Iters in parallel on two lists until the first list is empty.
+ The second one can be shorter and is padded with a default value.
+ This function cannot fail. *)
+val list_iter_default2: ('a -> 'b -> unit) -> 'a list -> 'b -> 'b list -> unit
+
(** split_nth n l
* @returns two list, the first contains at least n elements, the second the
let shift_k e (c,rf,x) = e::c,List.map (fun (k,v) -> k+1,v) rf,x+1;;
+(* for debugging only
let string_of_recfuns ~subst ~metasenv ~context l =
let pp = PP.ppterm ~subst ~metasenv ~context in
let safe, rest = List.partition (function (_,Safe) -> true | _ -> false) l in
(function (i,Evil rno)->pp(C.Rel i)^"/"^string_of_int rno
| _ -> assert false) dang)
;;
+*)
let fixed_args bos j n nn =
let rec aux k acc = function
(let rec f = function 0 -> [] | n -> true :: f (n-1) in f j) bos
;;
-let rec list_iter_default2 f l1 def l2 =
- match l1,l2 with
- | [], _ -> ()
- | a::ta, b::tb -> f a b; list_iter_default2 f ta def tb
- | a::ta, [] -> f a def; list_iter_default2 f ta def []
-;;
-
let rec split_prods ~subst context n te =
match (n, R.whd ~subst context te) with
| (0, _) -> context,te
List.iter (aux k) tl
| C.Appl ((C.Rel m)::tl) when is_unfolded m recfuns ->
let fixed_args = get_fixed_args m recfuns in
- list_iter_default2 (fun x b -> if not b then aux k x) tl false fixed_args
+ HExtlib.list_iter_default2
+ (fun x b -> if not b then aux k x) tl false fixed_args
| C.Rel m ->
(match List.nth context (m-1) with
| _,C.Decl _ -> ()
let ctx_len = List.length context in
(* we may look for fixed params not only up to j ... *)
let fa = fixed_args bos j ctx_len (ctx_len + fl_len) in
- list_iter_default2 (fun x b -> if not b then aux k x) args false fa;
+ HExtlib.list_iter_default2
+ (fun x b -> if not b then aux k x) args false fa;
let context = context@ctx_tys in
let ctx_len = List.length context in
let extra_recfuns =