]> matita.cs.unibo.it Git - helm.git/commitdiff
added list_uniq
authorStefano Zacchiroli <zack@upsilon.cc>
Tue, 27 Sep 2005 14:12:16 +0000 (14:12 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Tue, 27 Sep 2005 14:12:16 +0000 (14:12 +0000)
helm/ocaml/extlib/.depend
helm/ocaml/extlib/hExtlib.ml
helm/ocaml/extlib/hExtlib.mli

index 3ca72a4d90aee9787f40ba281d6f9b18d2d8008a..e4598cb4ff6d7736aa3920b432e1e49bd6e79478 100644 (file)
@@ -1,4 +1,4 @@
 hExtlib.cmo: hExtlib.cmi 
 hExtlib.cmx: hExtlib.cmi 
-hMysql.cmo: hMysql.cmi 
-hMysql.cmx: hMysql.cmi 
+hMysql.cmo: hExtlib.cmi hMysql.cmi 
+hMysql.cmx: hExtlib.cmx hMysql.cmi 
index b8bee56568f08d36bb9816bf295f9b2e0649a0db..06ac37b13c19197dfa5245f4afd16af5dec27acc 100644 (file)
@@ -88,8 +88,13 @@ let trim_blanks s =
   let left, right = find_left 0, find_right (s_len - 1) in
   String.sub s left (right - left + 1)
 
-(*   let rex = Pcre.regexp "^\\s*(.*?)\\s*$" in
-  fun s -> (Pcre.extract ~rex s).(1) *)
+(** {2 List processing} *)
+
+let rec list_uniq = function 
+  | [] -> []
+  | h::[] -> [h]
+  | h1::h2::tl when h1 = h2 -> list_uniq (h2 :: tl) 
+  | h1::tl (* when h1 <> h2 *) -> h1 :: list_uniq tl
 
 (** {2 File predicates} *)
 
index ad055315e077faf337f0d937fb2b516eada03eab..cd4cc276ebc8a5084dbdde08c7deae2a6f0e471e 100644 (file)
@@ -49,6 +49,10 @@ val finally: (unit -> unit) -> ('a -> 'b) -> 'a -> 'b
 val split: ?sep:char -> string -> string list (** @param sep defaults to ' ' *)
 val trim_blanks: string -> string (** strip heading and trailing blanks *)
 
+(** {2 List processing} *)
+
+val list_uniq: 'a list -> 'a list (* uniq unix filter on lists *)
+
 (** {2 Debugging & Profiling} *)
 
 type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }