]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/extlib/hExtlib.ml
Inductive definitions are now interpreted (but records are not interpreted yet).
[helm.git] / helm / software / components / extlib / hExtlib.ml
index e2063e451a692ccb25fa045de3f88b21c726a499..3ef795e9fca4badc9299cd2a0f4207fe1af2afa5 100644 (file)
@@ -148,6 +148,16 @@ let list_mapi f l =
      aux 0 l
 ;;
 
+let list_index p =
+ let rec aux n =
+  function
+     [] -> None
+   | he::_ when p he -> Some (n,he)
+   | _::tl -> aux (n + 1) tl
+ in
+  aux 0
+;;
+
 let rec list_iter_default2 f l1 def l2 = 
   match l1,l2 with
     | [], _ -> ()
@@ -239,14 +249,14 @@ let list_concat ?(sep = []) =
   aux []
   
 let rec list_findopt f l = 
-  let rec aux = function 
+  let rec aux = function 
     | [] -> None 
     | x::tl -> 
-        (match f x with
-        | None -> aux tl
+        (match f x with
+        | None -> aux (succ k) tl
         | Some _ as rc -> rc)
   in
-  aux l
+  aux l
 
 let split_nth n l =
   let rec aux acc n l =
@@ -464,7 +474,7 @@ let loc_of_floc floc = Stdpp.first_pos floc, Stdpp.last_pos floc;;
 let floc_of_loc (loc_begin, loc_end) =
  Stdpp.make_loc (loc_begin, loc_end)
 
-let dummy_floc = floc_of_loc (-1, -1)
+let dummy_floc = floc_of_loc (0, 0)
 
 let raise_localized_exception ~offset floc exn =
  let x, y = loc_of_floc floc in
@@ -539,6 +549,7 @@ let rec mk_list x = function
 ;;
 
 let list_seq start stop =
+  if start > stop then [] else
   let rec aux pos =
     if pos = stop then []
     else pos :: (aux (pos+1))