rearrange some stuff
This commit is contained in:
parent
5c59d80e00
commit
6ac8be6984
10 changed files with 84 additions and 51 deletions
15
set_ext.ml
Normal file
15
set_ext.ml
Normal file
|
@ -0,0 +1,15 @@
|
|||
module type S = sig
|
||||
include Set.S
|
||||
val exists_opt: (elt -> 'a option) -> t -> 'a option
|
||||
end
|
||||
|
||||
module Make(Elt: Set.OrderedType) = struct
|
||||
include Set.Make(Elt)
|
||||
|
||||
let exists_opt (type a) (f: elt -> a option) set =
|
||||
let exception Found of a in
|
||||
let f' x = Option.iter (fun x -> raise (Found x)) (f x) in
|
||||
match iter f' set with
|
||||
| exception Found x -> Some x
|
||||
| _ -> None
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue