]> matita.cs.unibo.it Git - helm.git/blob - helm/software/lambda-delta/lib/cps.ml
- we updated some preambles to match that of nUri.ml
[helm.git] / helm / software / lambda-delta / lib / cps.ml
1 (*
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.                     
5     ||I||                                                                
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_______________________________________________________________ *)
11
12 let start x = x
13
14 let id f x = f x
15
16 let rec list_sub_strict f l1 l2 = match l1, l2 with
17    | _, []              -> f l1
18    | _ :: tl1, _ :: tl2 -> list_sub_strict f tl1 tl2
19    | _                  -> assert false
20
21 let rec list_fold_left f map a = function
22    | []       -> f a
23    | hd :: tl -> 
24       let f a = list_fold_left f map a tl in
25       map f a hd
26
27 let rec list_rev_map_append f map ~tail = function
28       | []       -> f tail        
29       | hd :: tl ->
30          let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in
31          map f hd
32
33 let list_rev_append f =
34    list_rev_map_append f (fun f t -> f t)
35
36 let list_rev_map =
37    list_rev_map_append ~tail:[]
38
39 let list_rev =
40    list_rev_append ~tail:[]
41
42 let list_map f =
43    list_rev_map (list_rev f)
44