@@ -22375,6 +22375,8 @@ val map_append : ('b -> 'a) -> 'b list -> 'a list -> 'a list
22375
22375
22376
22376
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
22377
22377
22378
+ val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
22379
+
22378
22380
(** Extension to the standard library [List] module *)
22379
22381
22380
22382
(** TODO some function are no efficiently implemented. *)
@@ -22625,6 +22627,22 @@ let rec fold_right f l acc =
22625
22627
| a0::a1::a2::a3::a4::rest ->
22626
22628
f a0 (f a1 (f a2 (f a3 (f a4 (fold_right f rest acc)))))
22627
22629
22630
+ let rec fold_right2 f l r acc =
22631
+ match l,r with
22632
+ | [],[] -> acc
22633
+ | [a0],[b0] -> f a0 b0 acc
22634
+ | [a0;a1],[b0;b1] -> f a0 b0 (f a1 b1 acc)
22635
+ | [a0;a1;a2],[b0;b1;b2] -> f a0 b0 (f a1 b1 (f a2 b2 acc))
22636
+ | [a0;a1;a2;a3],[b0;b1;b2;b3] ->
22637
+ f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 acc)))
22638
+ | [a0;a1;a2;a3;a4], [b0;b1;b2;b3;b4] ->
22639
+ f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 acc))))
22640
+ | a0::a1::a2::a3::a4::arest, b0::b1::b2::b3::b4::brest ->
22641
+ f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 (fold_right2 f arest brest acc)))))
22642
+ | _, _ -> invalid_arg "Ext_list.fold_right2"
22643
+
22644
+
22645
+
22628
22646
let rec filter_map (f: 'a -> 'b option) xs =
22629
22647
match xs with
22630
22648
| [] -> []
@@ -22764,13 +22782,6 @@ let rec map_last f l1 =
22764
22782
| a1::l1 -> let r = f false a1 in r :: map_last f l1
22765
22783
22766
22784
22767
- (* let rec fold_right2_last f l1 l2 accu =
22768
- match (l1, l2) with
22769
- | ([], []) -> accu
22770
- | [last1], [last2] -> f true last1 last2 accu
22771
- | (a1::l1, a2::l2) -> f false a1 a2 (fold_right2_last f l1 l2 accu)
22772
- | (_, _) -> invalid_arg "List.fold_right2" *)
22773
-
22774
22785
22775
22786
let init n f =
22776
22787
Array.to_list (Array.init n f)
@@ -26460,7 +26471,7 @@ let from_labels ~loc arity labels
26460
26471
(Typ.object_ ~loc
26461
26472
(List.map2 (fun x y -> x.Asttypes.txt ,[], y) labels tyvars) Closed)
26462
26473
in
26463
- List .fold_right2
26474
+ Ext_list .fold_right2
26464
26475
(fun {Asttypes.loc ; txt = label }
26465
26476
tyvar acc -> Typ.arrow ~loc label tyvar acc) labels tyvars result_type
26466
26477
@@ -90765,7 +90776,7 @@ let subst name export_set stats =
90765
90776
(* (Js_dump.string_of_block [st]); *)
90766
90777
Js_op_util.update_used_stats v.ident_info Dead_pure;
90767
90778
let block =
90768
- List .fold_right2 (fun param arg acc -> S.define ~kind:Variable param arg :: acc)
90779
+ Ext_list .fold_right2 (fun param arg acc -> S.define ~kind:Variable param arg :: acc)
90769
90780
params args ( self#block block) (* see #278 before changes*)
90770
90781
90771
90782
in
@@ -91971,7 +91982,7 @@ let handle_exports (meta : Lam_stats.t)
91971
91982
let len = List.length original_exports in
91972
91983
let tbl = String_hash_set.create len in
91973
91984
let ({export_list ; export_set ; groups = coercion_groups } as result) =
91974
- List .fold_right2
91985
+ Ext_list .fold_right2
91975
91986
(fun (original_export_id : Ident.t) (lam : Lam.t) (acc : t) ->
91976
91987
let original_name = original_export_id.name in
91977
91988
if not @@ String_hash_set.check_add tbl original_name then
@@ -100726,10 +100737,10 @@ let subst_helper (subst : subst_tbl) (query : int -> int) lam =
100726
100737
let handler = to_lam handler in
100727
100738
let ys = Ext_list.map Ident.rename xs in
100728
100739
let env =
100729
- List .fold_right2
100740
+ Ext_list .fold_right2
100730
100741
(fun x y t -> Ident_map.add x (Lam.var y) t)
100731
100742
xs ys Ident_map.empty in
100732
- List .fold_right2
100743
+ Ext_list .fold_right2
100733
100744
(fun y l r -> Lam.let_ Alias y l r)
100734
100745
ys ls
100735
100746
(Lam_subst.subst env handler)
@@ -107947,7 +107958,7 @@ let ocaml_obj_as_js_object
107947
107958
Location.raise_errorf ~loc "Only method support currently"
107948
107959
) clfs ([], [], [], false) in
107949
107960
let pval_type =
107950
- List .fold_right2
107961
+ Ext_list .fold_right2
107951
107962
(fun label label_type acc ->
107952
107963
Typ.arrow
107953
107964
~loc:label.Asttypes.loc
0 commit comments