merge with github's master

This commit is contained in:
Simon Cruanes 2014-11-08 01:04:49 +01:00
commit 7197313d91
2 changed files with 9 additions and 0 deletions

View file

@ -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

View file

@ -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 *)