From 83994f1f5e3c78bf7d23fc68acf677913d70ecb5 Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 1 Jan 2015 17:43:27 -0500 Subject: [PATCH] infix map operators for CCArray --- src/core/CCArray.ml | 4 ++++ src/core/CCArray.mli | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/core/CCArray.ml b/src/core/CCArray.ml index 32634263..e4e10882 100644 --- a/src/core/CCArray.ml +++ b/src/core/CCArray.ml @@ -392,6 +392,10 @@ let lookup ?(cmp=Pervasives.compare) k a = let (>>=) a f = flat_map f a +let (>>|) a f = map f a + +let (>|=) a f = map f a + let for_all p a = _for_all p a 0 (Array.length a) let exists p a = _exists p a 0 (Array.length a) diff --git a/src/core/CCArray.mli b/src/core/CCArray.mli index 51665df7..1a5c26a4 100644 --- a/src/core/CCArray.mli +++ b/src/core/CCArray.mli @@ -155,6 +155,14 @@ val flat_map : ('a -> 'b t) -> 'a t -> 'b array val (>>=) : 'a t -> ('a -> 'b t) -> 'b t (** Infix version of {!flat_map} *) +val (>>|) : 'a t -> ('a -> 'b) -> 'b t +(** Infix version of {!map} + @since NEXT_RELEASE *) + +val (>|=) : 'a t -> ('a -> 'b) -> 'b t +(** Infix version of {!map} + @since NEXT_RELEASE *) + val except_idx : 'a t -> int -> 'a list (** Remove given index, obtaining the list of the other elements *)