From 8b509d16d4e68dd6568d8d091c0464d4fcefb0fa Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 11 May 2009 21:42:08 +0000 Subject: [PATCH] New function list_iter_sep. --- helm/software/components/extlib/hExtlib.ml | 9 +++++++++ helm/software/components/extlib/hExtlib.mli | 1 + 2 files changed, 10 insertions(+) diff --git a/helm/software/components/extlib/hExtlib.ml b/helm/software/components/extlib/hExtlib.ml index 5f2c7f78c..b2092c5b3 100644 --- a/helm/software/components/extlib/hExtlib.ml +++ b/helm/software/components/extlib/hExtlib.ml @@ -248,6 +248,15 @@ let list_concat ?(sep = []) = in aux [] +let list_iter_sep ~sep f = + let rec aux = + function + | [] -> () + | [ last ] -> f last + | hd :: tl -> f hd; sep (); aux tl + in + aux + let rec list_findopt f l = let rec aux k = function | [] -> None diff --git a/helm/software/components/extlib/hExtlib.mli b/helm/software/components/extlib/hExtlib.mli index 69843b235..20e6c0192 100644 --- a/helm/software/components/extlib/hExtlib.mli +++ b/helm/software/components/extlib/hExtlib.mli @@ -87,6 +87,7 @@ val filter_map: ('a -> 'b option) -> 'a list -> 'b list (** filter + map *) val list_rev_map_filter: ('a -> 'b option) -> 'a list -> 'b list val list_rev_map_filter_fold: ('c -> 'a -> 'c * 'b option) -> 'c -> 'a list -> 'c * 'b list val list_concat: ?sep:'a list -> 'a list list -> 'a list (**String.concat-like*) +val list_iter_sep: sep:(unit -> unit) -> ('a -> unit) -> 'a list -> unit val list_findopt: ('a -> int -> 'b option) -> 'a list -> 'b option val flatten_map: ('a -> 'b list) -> 'a list -> 'b list val list_last: 'a list -> 'a -- 2.39.2