diff options
| author | Théo Zimmermann | 2018-07-21 20:25:27 +0200 |
|---|---|---|
| committer | Théo Zimmermann | 2018-08-27 20:00:00 +0200 |
| commit | d5c9c90b9760bd51136f0ccbb041f8697ad0a081 (patch) | |
| tree | d64111dda6c4af12eb15aa3a0570d4b9c0c6cf19 /clib | |
| parent | bce734bfb2a118dbb487e5b88eba524ca14d2078 (diff) | |
Add support for focusing on named goals using brackets.
Diffstat (limited to 'clib')
| -rw-r--r-- | clib/cList.ml | 3 | ||||
| -rw-r--r-- | clib/cList.mli | 4 |
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. *) |
