2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
16 let rec list_sub_strict f l1 l2 = match l1, l2 with
18 | _ :: tl1, _ :: tl2 -> list_sub_strict f tl1 tl2
21 let rec list_fold_left f map a = function
24 let f a = list_fold_left f map a tl in
27 let rec list_rev_map_append f map ~tail = function
30 let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in
33 let rec list_forall2 f map l1 l2 = match l1, l2 with
35 | hd1 :: tl1, hd2 :: tl2 ->
36 let f b = if b then list_forall2 f map tl1 tl2 else f false in
40 let list_rev_append f =
41 list_rev_map_append f (fun f t -> f t)
44 list_rev_map_append ~tail:[]
47 list_rev_append ~tail:[]
49 let list_fold_right f map l a =
50 let map f a m = map f m a in
51 list_rev (list_fold_left f map a) l
54 list_rev_map (list_rev f)
56 let list_iter f map l =
57 let map f () x = map f x in
58 list_fold_left f map () l
60 let rec list_fold_left2 f map a l1 l2 = match l1, l2 with
62 | hd1 :: tl1, hd2 :: tl2 ->
63 let f a = if a = None then f a else list_fold_left2 f map a tl1 tl2 in