mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
add CCOpt.if_
This commit is contained in:
parent
777796d8a6
commit
07d11c4104
2 changed files with 6 additions and 0 deletions
|
|
@ -71,6 +71,8 @@ let filter p = function
|
|||
| Some x as o when p x -> o
|
||||
| o -> o
|
||||
|
||||
let if_ p x = if p x then Some x else None
|
||||
|
||||
let exists p = function
|
||||
| None -> false
|
||||
| Some x -> p x
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ val filter : ('a -> bool) -> 'a t -> 'a t
|
|||
(** Filter on 0 or 1 element
|
||||
@since 0.5 *)
|
||||
|
||||
val if_ : ('a -> bool) -> 'a -> 'a option
|
||||
(** [if_ f x] is [Some x] if [f x], [None] otherwise
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val exists : ('a -> bool) -> 'a t -> bool
|
||||
(** @since NEXT_RELEASE *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue