mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCArray.Infix
This commit is contained in:
parent
beb38da150
commit
3658864a5a
3 changed files with 63 additions and 0 deletions
|
|
@ -688,3 +688,12 @@ let sort_generic (type arr)(type elt)
|
||||||
Array.sort CCInt.compare a1; sort_generic (module IA) ~cmp:CCInt.compare a2; \
|
Array.sort CCInt.compare a1; sort_generic (module IA) ~cmp:CCInt.compare a2; \
|
||||||
a1 = a2 )
|
a1 = a2 )
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
|
||||||
|
module Infix = struct
|
||||||
|
let (>>=) = (>>=)
|
||||||
|
let (>>|) = (>>|)
|
||||||
|
let (>|=) = (>|=)
|
||||||
|
let (--) = (--)
|
||||||
|
let (--^) = (--^)
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -341,3 +341,30 @@ val sort_generic :
|
||||||
(** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though).
|
(** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though).
|
||||||
Performance might be lower than {!Array.sort}.
|
Performance might be lower than {!Array.sort}.
|
||||||
@since 0.14 *)
|
@since 0.14 *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {3 Infix Operators} *)
|
||||||
|
It is convenient to {!open CCArray.Infix} to access the infix operators
|
||||||
|
without cluttering the scope too much.
|
||||||
|
|
||||||
|
@since 2.7 *)
|
||||||
|
|
||||||
|
module Infix : sig
|
||||||
|
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||||
|
(** [a >>= f] is the infix version of {!flat_map}. *)
|
||||||
|
|
||||||
|
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
(** [a >>| f] is the infix version of {!map}.
|
||||||
|
@since 0.8 *)
|
||||||
|
|
||||||
|
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
(** [a >|= f] is the infix version of {!map}.
|
||||||
|
@since 0.8 *)
|
||||||
|
|
||||||
|
val (--) : int -> int -> int t
|
||||||
|
(** [x -- y] creates an array containing integers in the range [x .. y]. Bounds included. *)
|
||||||
|
|
||||||
|
val (--^) : int -> int -> int t
|
||||||
|
(** [x --^ y] creates an array containing integers in the range [x .. y]. Right bound excluded.
|
||||||
|
@since 0.17 *)
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -342,3 +342,30 @@ val sort_generic :
|
||||||
(** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though).
|
(** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though).
|
||||||
Performance might be lower than {!Array.sort}.
|
Performance might be lower than {!Array.sort}.
|
||||||
@since 0.14 *)
|
@since 0.14 *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {3 Infix Operators} *)
|
||||||
|
It is convenient to {!open CCArray.Infix} to access the infix operators
|
||||||
|
without cluttering the scope too much.
|
||||||
|
|
||||||
|
@since 2.7 *)
|
||||||
|
|
||||||
|
module Infix : sig
|
||||||
|
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||||
|
(** [a >>= f] is the infix version of {!flat_map}. *)
|
||||||
|
|
||||||
|
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
(** [a >>| f] is the infix version of {!map}.
|
||||||
|
@since 0.8 *)
|
||||||
|
|
||||||
|
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
(** [a >|= f] is the infix version of {!map}.
|
||||||
|
@since 0.8 *)
|
||||||
|
|
||||||
|
val (--) : int -> int -> int t
|
||||||
|
(** [x -- y] creates an array containing integers in the range [x .. y]. Bounds included. *)
|
||||||
|
|
||||||
|
val (--^) : int -> int -> int t
|
||||||
|
(** [x --^ y] creates an array containing integers in the range [x .. y]. Right bound excluded.
|
||||||
|
@since 0.17 *)
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue