]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/components/binaries/matex/ground.ml
auxiliary executables (xoa, matitadep, probe, matex) ported to dune
[helm.git] / matita / components / binaries / matex / ground.ml
index 0e9f28c55bb0578b95f89f8e96957b508b26dd65..3c75b4032d6dfd6620334d31a14e0d5e3f024c64 100644 (file)
@@ -9,7 +9,7 @@
      \ /   This software is distributed as is, NO WARRANTY.     
       V_______________________________________________________________ *)
 
-module L = List
+(* module L = List *)
 module P = Printf
 module S = String
 
@@ -48,10 +48,21 @@ let rec foldi_left mapi i a = function
    | []       -> a
    | hd :: tl -> foldi_left mapi (succ i) (mapi i a hd) tl
 
+let rev_mapi mapi i l =
+   let map i a hd = mapi i hd :: a in
+   foldi_left map i [] l
+
 let rec rev_map_append map l r = match l with
    | []       -> r
    | hd :: tl -> rev_map_append map tl (map hd :: r)
 
+let rec split_at x = function
+   | l when x <= 0 -> [], l
+   | []       -> [], []
+   | hd :: tl -> 
+      let l1, l2 = split_at (pred x) tl in
+      hd :: l1, l2
+
 let error s = raise (Error s)
 
 let log s = P.eprintf "MaTeX: %s\n%!" s