]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/basic_rg/brg.ml
basic_rg: reduction was not tail recursive by mistake
[helm.git] / helm / software / lambda-delta / basic_rg / brg.ml
index baa83afed3741ca6f94637fec132262d7294a851..e7768238128dda734fb8202e7090bb72e4c7e222 100644 (file)
@@ -60,8 +60,7 @@ let bind_abbr a v t = Bind (Abbr (a, v), t)
 
 let empty_lenv = Null
 
-let push f es ?c b =
-   let es = Cons (es, c, b) in f es
+let push es ?c b = Cons (es, c, b)
 
 let get err f es i =
    let rec aux j = function
@@ -72,6 +71,7 @@ let get err f es i =
    in
    aux i es
 
+(* check closure *)
 let rec rev_iter f map = function   
    | Null                 -> f ()
    | Cons (tl, None, b)   -> 
@@ -79,8 +79,6 @@ let rec rev_iter f map = function
    | Cons (tl, Some c, b) -> 
       let f _ = map f c b in rev_iter f map tl
 
-let rec fold_left f map x = function
-   | Null            -> f x
-   | Cons (tl, _, b) ->
-      let f x = fold_left f map x tl in
-      map f x b
+let rec fold_left map x = function
+   | Null            -> x
+   | Cons (tl, _, b) -> fold_left map (map x b) tl