aboutsummaryrefslogtreecommitdiff
path: root/clib
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2018-08-28 11:28:50 +0200
committerPierre-Marie Pédrot2018-08-28 11:28:50 +0200
commitf885e8a88620351d9dc4b0969f520d13197f2184 (patch)
treee9233c855e770e256dcc4dcb9fa5bb956069471f /clib
parent5e2eedb3f9068a87eda0d7e08c82127ddef224fb (diff)
parent7a7e39f8a0279a149c6b7c20f026cb629aa489f7 (diff)
Merge PR #8112: Add support for focusing on named goals using brackets.
Diffstat (limited to 'clib')
-rw-r--r--clib/cList.ml3
-rw-r--r--clib/cList.mli4
2 files changed, 7 insertions, 0 deletions
diff --git a/clib/cList.ml b/clib/cList.ml
index de42886dcb..dc59ff2970 100644
--- a/clib/cList.ml
+++ b/clib/cList.ml
@@ -60,6 +60,7 @@ sig
val extend : bool list -> 'a -> 'a list -> 'a list
val count : ('a -> bool) -> 'a list -> int
val index : 'a eq -> 'a -> 'a list -> int
+ val safe_index : 'a eq -> 'a -> 'a list -> int option
val index0 : 'a eq -> 'a -> 'a list -> int
val fold_left_until : ('c -> 'a -> 'c CSig.until) -> 'c -> 'a list -> 'c
val fold_right_i : (int -> 'a -> 'b -> 'b) -> int -> 'a list -> 'b -> 'b
@@ -538,6 +539,8 @@ let rec index_f f x l n = match l with
let index f x l = index_f f x l 1
+let safe_index f x l = try Some (index f x l) with Not_found -> None
+
let index0 f x l = index_f f x l 0
(** {6 Folding} *)
diff --git a/clib/cList.mli b/clib/cList.mli
index 42fae5ed39..ed468cb977 100644
--- a/clib/cList.mli
+++ b/clib/cList.mli
@@ -155,6 +155,10 @@ sig
val index : 'a eq -> 'a -> 'a list -> int
(** [index] returns the 1st index of an element in a list (counting from 1). *)
+ val safe_index : 'a eq -> 'a -> 'a list -> int option
+ (** [safe_index] returns the 1st index of an element in a list (counting from 1)
+ and None otherwise. *)
+
val index0 : 'a eq -> 'a -> 'a list -> int
(** [index0] behaves as [index] except that it starts counting at 0. *)