From 98aeb4f16c26a8512428918cfaa4bfa910a372d6 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 27 Sep 2005 14:12:16 +0000 Subject: [PATCH] added list_uniq --- helm/ocaml/extlib/.depend | 4 ++-- helm/ocaml/extlib/hExtlib.ml | 9 +++++++-- helm/ocaml/extlib/hExtlib.mli | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/helm/ocaml/extlib/.depend b/helm/ocaml/extlib/.depend index 3ca72a4d9..e4598cb4f 100644 --- a/helm/ocaml/extlib/.depend +++ b/helm/ocaml/extlib/.depend @@ -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 diff --git a/helm/ocaml/extlib/hExtlib.ml b/helm/ocaml/extlib/hExtlib.ml index b8bee5656..06ac37b13 100644 --- a/helm/ocaml/extlib/hExtlib.ml +++ b/helm/ocaml/extlib/hExtlib.ml @@ -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} *) diff --git a/helm/ocaml/extlib/hExtlib.mli b/helm/ocaml/extlib/hExtlib.mli index ad055315e..cd4cc276e 100644 --- a/helm/ocaml/extlib/hExtlib.mli +++ b/helm/ocaml/extlib/hExtlib.mli @@ -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 } -- 2.39.2