mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 19:25:28 -05:00
merge with github's master
This commit is contained in:
commit
7197313d91
2 changed files with 9 additions and 0 deletions
|
|
@ -84,6 +84,10 @@ let map2 f o1 o2 = match o1, o2 with
|
||||||
| _, None -> None
|
| _, None -> None
|
||||||
| Some x, Some y -> Some (f x y)
|
| Some x, Some y -> Some (f x y)
|
||||||
|
|
||||||
|
let filter p = function
|
||||||
|
| Some x as o when p x -> o
|
||||||
|
| o -> o
|
||||||
|
|
||||||
let iter f o = match o with
|
let iter f o = match o with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some x -> f x
|
| Some x -> f x
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ val iter : ('a -> unit) -> 'a t -> unit
|
||||||
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
|
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
|
||||||
(** Fold on 0 or 1 elements *)
|
(** Fold on 0 or 1 elements *)
|
||||||
|
|
||||||
|
val filter : ('a -> bool) -> 'a t -> 'a t
|
||||||
|
(** Filter on 0 or 1 elements
|
||||||
|
|
||||||
|
@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 NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue