From 9bb529b1b6620f1cbb249104ef9303b130acb315 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Sat, 25 Apr 2009 20:28:07 +0000 Subject: [PATCH] Type for list_index improved. --- helm/software/components/extlib/hExtlib.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helm/software/components/extlib/hExtlib.ml b/helm/software/components/extlib/hExtlib.ml index 523913cbf..3ef795e9f 100644 --- a/helm/software/components/extlib/hExtlib.ml +++ b/helm/software/components/extlib/hExtlib.ml @@ -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 | [], _ -> () -- 2.39.2