(* ||M|| This file is part of HELM, an Hypertextual, Electronic ||A|| Library of Mathematics, developed at the Computer Science ||T|| Department, University of Bologna, Italy. ||I|| ||T|| HELM is free software; you can redistribute it and/or ||A|| modify it under the terms of the GNU General Public License \ / version 2 or (at your option) any later version. \ / This software is distributed as is, NO WARRANTY. V_______________________________________________________________ *) let start x = x let id f x = f x let rec list_sub_strict f l1 l2 = match l1, l2 with | _, [] -> f l1 | _ :: tl1, _ :: tl2 -> list_sub_strict f tl1 tl2 | _ -> assert false let rec list_fold_left f map a = function | [] -> f a | hd :: tl -> let f a = list_fold_left f map a tl in map f a hd let rec list_rev_map_append f map ~tail = function | [] -> f tail | hd :: tl -> let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in map f hd let rec forall2 f map l1 l2 = match l1, l2 with | [], [] -> f true | hd1 :: tl1, hd2 :: tl2 -> let f b = if b then forall2 f map tl1 tl2 else f false in map f hd1 hd2 | _ -> f false let list_rev_append f = list_rev_map_append f (fun f t -> f t) let list_rev_map = list_rev_map_append ~tail:[] let list_rev = list_rev_append ~tail:[] let list_map f = list_rev_map (list_rev f)