mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCOpt.{for_all, exists}
This commit is contained in:
parent
037f169044
commit
dba88f5302
2 changed files with 14 additions and 0 deletions
|
|
@ -71,6 +71,14 @@ let filter p = function
|
||||||
| Some x as o when p x -> o
|
| Some x as o when p x -> o
|
||||||
| o -> o
|
| o -> o
|
||||||
|
|
||||||
|
let exists p = function
|
||||||
|
| None -> false
|
||||||
|
| Some x -> p x
|
||||||
|
|
||||||
|
let for_all p = function
|
||||||
|
| None -> true
|
||||||
|
| Some x -> p x
|
||||||
|
|
||||||
let iter f o = match o with
|
let iter f o = match o with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some x -> f x
|
| Some x -> f x
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,12 @@ val filter : ('a -> bool) -> 'a t -> 'a t
|
||||||
(** Filter on 0 or 1 element
|
(** Filter on 0 or 1 element
|
||||||
@since 0.5 *)
|
@since 0.5 *)
|
||||||
|
|
||||||
|
val exists : ('a -> bool) -> 'a t -> bool
|
||||||
|
(** @since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
val for_all : ('a -> bool) -> 'a t -> bool
|
||||||
|
(** @since NEXT_RELEASE *)
|
||||||
|
|
||||||
val get : 'a -> 'a t -> 'a
|
val get : 'a -> 'a t -> 'a
|
||||||
(** [get default x] unwraps [x], but if [x = None] it returns [default] instead.
|
(** [get default x] unwraps [x], but if [x = None] it returns [default] instead.
|
||||||
@since 0.4.1 *)
|
@since 0.4.1 *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue