This commit is contained in:
Simon Cruanes 2018-01-21 14:39:44 -06:00
parent f98bcffaee
commit bc27e60a81
12 changed files with 185 additions and 185 deletions

View file

@ -29,12 +29,12 @@ val swap : 'a t -> int -> int -> unit
val get : 'a t -> int -> 'a val get : 'a t -> int -> 'a
(** [get a n] returns the element number [n] of array [a]. (** [get a n] returns the element number [n] of array [a].
The first element has number 0. The first element has number 0.
The last element has number [length a - 1]. The last element has number [length a - 1].
You can also write [a.(n)] instead of [get a n]. You can also write [a.(n)] instead of [get a n].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [(length a - 1)]. *) if [n] is outside the range 0 to [(length a - 1)]. *)
val get_safe : 'a t -> int -> 'a option val get_safe : 'a t -> int -> 'a option
(** [get_safe a i] returns [Some a.(i)] if [i] is a valid index. (** [get_safe a i] returns [Some a.(i)] if [i] is a valid index.
@ -42,18 +42,18 @@ val get_safe : 'a t -> int -> 'a option
val set : 'a t -> int -> 'a -> unit val set : 'a t -> int -> 'a -> unit
(** [set a n x] modifies array [a] in place, replacing (** [set a n x] modifies array [a] in place, replacing
element number [n] with [x]. element number [n] with [x].
You can also write [a.(n) <- x] instead of [set a n x]. You can also write [a.(n) <- x] instead of [set a n x].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [length a - 1]. *) if [n] is outside the range 0 to [length a - 1]. *)
val length : _ t -> int val length : _ t -> int
(** Return the length (number of elements) of the given array. *) (** Return the length (number of elements) of the given array. *)
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)], (** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)],
where [n] is the length of the array [a]. *) where [n] is the length of the array [a]. *)
val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** Fold left on array, with index. *) (** Fold left on array, with index. *)
@ -75,24 +75,24 @@ val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc t
val iter : ('a -> unit) -> 'a t -> unit val iter : ('a -> unit) -> 'a t -> unit
(** [iter f a] applies function [f] in turn to all (** [iter f a] applies function [f] in turn to all
the elements of [a]. It is equivalent to the elements of [a]. It is equivalent to
[f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *) [f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *)
val iteri : (int -> 'a -> unit) -> 'a t -> unit val iteri : (int -> 'a -> unit) -> 'a t -> unit
(** Same as {!Array.iter}, but the (** Same as {!Array.iter}, but the
function is applied with the index of the element as first argument, function is applied with the index of the element as first argument,
and the element itself as second argument. *) and the element itself as second argument. *)
val blit : 'a t -> int -> 'a t -> int -> int -> unit val blit : 'a t -> int -> 'a t -> int -> int -> unit
(** [blit v1 o1 v2 o2 len] copies [len] elements (** [blit v1 o1 v2 o2 len] copies [len] elements
from array [v1], starting at element number [o1], to array [v2], from array [v1], starting at element number [o1], to array [v2],
starting at element number [o2]. It works correctly even if starting at element number [o2]. It works correctly even if
[v1] and [v2] are the same array, and the source and [v1] and [v2] are the same array, and the source and
destination chunks overlap. destination chunks overlap.
Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not
designate a valid subarray of [v1], or if [o2] and [len] do not designate a valid subarray of [v1], or if [o2] and [len] do not
designate a valid subarray of [v2]. *) designate a valid subarray of [v2]. *)
val reverse_in_place : 'a t -> unit val reverse_in_place : 'a t -> unit
(** Reverse the array in place. *) (** Reverse the array in place. *)
@ -177,8 +177,8 @@ val bsearch : cmp:('a -> 'a -> int) -> 'a -> 'a t ->
val for_all : ('a -> bool) -> 'a t -> bool val for_all : ('a -> bool) -> 'a t -> bool
(** [for_all p [|a1; ...; an|]] checks if all elements of the array (** [for_all p [|a1; ...; an|]] checks if all elements of the array
satisfy the predicate [p]. That is, it returns satisfy the predicate [p]. That is, it returns
[(p a1) && (p a2) && ... && (p an)]. *) [(p a1) && (p a2) && ... && (p an)]. *)
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** Forall on pairs of arrays. (** Forall on pairs of arrays.
@ -231,13 +231,13 @@ val pp_i: ?sep:string -> (int -> 'a printer) -> 'a t printer
val map : ('a -> 'b) -> 'a t -> 'b t val map : ('a -> 'b) -> 'a t -> 'b t
(** [map f a] applies function [f] to all the elements of [a], (** [map f a] applies function [f] to all the elements of [a],
and builds an array with the results returned by [f]: and builds an array with the results returned by [f]:
[[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *) [[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *)
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
(** [map2 f a b] applies function [f] to all the elements of [a] and [b], (** [map2 f a b] applies function [f] to all the elements of [a] and [b],
and builds an array with the results returned by [f]: and builds an array with the results returned by [f]:
[[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]]. [[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]].
@raise Invalid_argument if they have distinct lengths. @raise Invalid_argument if they have distinct lengths.
@since 0.20 *) @since 0.20 *)

View file

@ -25,12 +25,12 @@ val compare : 'a ord -> 'a t ord
val get : 'a t -> int -> 'a val get : 'a t -> int -> 'a
(** [get a n] returns the element number [n] of array [a]. (** [get a n] returns the element number [n] of array [a].
The first element has number 0. The first element has number 0.
The last element has number [length a - 1]. The last element has number [length a - 1].
You can also write [a.(n)] instead of [get a n]. You can also write [a.(n)] instead of [get a n].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [(length a - 1)]. *) if [n] is outside the range 0 to [(length a - 1)]. *)
val get_safe : 'a t -> int -> 'a option val get_safe : 'a t -> int -> 'a option
(** [get_safe a i] returns [Some a.(i)] if [i] is a valid index. (** [get_safe a i] returns [Some a.(i)] if [i] is a valid index.
@ -38,18 +38,18 @@ val get_safe : 'a t -> int -> 'a option
val set : 'a t -> int -> 'a -> unit val set : 'a t -> int -> 'a -> unit
(** [set a n x] modifies array [a] in place, replacing (** [set a n x] modifies array [a] in place, replacing
element number [n] with [x]. element number [n] with [x].
You can also write [a.(n) <- x] instead of [set a n x]. You can also write [a.(n) <- x] instead of [set a n x].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [length a - 1]. *) if [n] is outside the range 0 to [length a - 1]. *)
val length : _ t -> int val length : _ t -> int
(** Return the length (number of elements) of the given array. *) (** Return the length (number of elements) of the given array. *)
val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a
(** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)], (** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)],
where [n] is the length of the array [a]. *) where [n] is the length of the array [a]. *)
val foldi : f:('a -> int -> 'b -> 'a) -> init:'a -> 'b t -> 'a val foldi : f:('a -> int -> 'b -> 'a) -> init:'a -> 'b t -> 'a
(** Fold left on array, with index. *) (** Fold left on array, with index. *)
@ -61,24 +61,24 @@ val fold_while : f:('a -> 'b -> 'a * [`Stop | `Continue]) -> init:'a -> 'b t ->
val iter : f:('a -> unit) -> 'a t -> unit val iter : f:('a -> unit) -> 'a t -> unit
(** [iter f a] applies function [f] in turn to all (** [iter f a] applies function [f] in turn to all
the elements of [a]. It is equivalent to the elements of [a]. It is equivalent to
[f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *) [f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *)
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit val iteri : f:(int -> 'a -> unit) -> 'a t -> unit
(** Same as {!Array.iter}, but the (** Same as {!Array.iter}, but the
function is applied with the index of the element as first argument, function is applied with the index of the element as first argument,
and the element itself as second argument. *) and the element itself as second argument. *)
val blit : 'a t -> int -> 'a t -> int -> int -> unit val blit : 'a t -> int -> 'a t -> int -> int -> unit
(** [blit v1 o1 v2 o2 len] copies [len] elements (** [blit v1 o1 v2 o2 len] copies [len] elements
from array [v1], starting at element number [o1], to array [v2], from array [v1], starting at element number [o1], to array [v2],
starting at element number [o2]. It works correctly even if starting at element number [o2]. It works correctly even if
[v1] and [v2] are the same array, and the source and [v1] and [v2] are the same array, and the source and
destination chunks overlap. destination chunks overlap.
Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not
designate a valid subarray of [v1], or if [o2] and [len] do not designate a valid subarray of [v1], or if [o2] and [len] do not
designate a valid subarray of [v2]. *) designate a valid subarray of [v2]. *)
val reverse_in_place : 'a t -> unit val reverse_in_place : 'a t -> unit
(** Reverse the array in place. *) (** Reverse the array in place. *)
@ -153,8 +153,8 @@ val bsearch : cmp:('a -> 'a -> int) -> key:'a -> 'a t ->
val for_all : f:('a -> bool) -> 'a t -> bool val for_all : f:('a -> bool) -> 'a t -> bool
(** [for_all p [|a1; ...; an|]] checks if all elements of the array (** [for_all p [|a1; ...; an|]] checks if all elements of the array
satisfy the predicate [p]. That is, it returns satisfy the predicate [p]. That is, it returns
[(p a1) && (p a2) && ... && (p an)]. *) [(p a1) && (p a2) && ... && (p an)]. *)
val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** Forall on pairs of arrays. (** Forall on pairs of arrays.
@ -207,13 +207,13 @@ val pp_i: ?sep:string -> (int -> 'a printer) -> 'a t printer
val map : f:('a -> 'b) -> 'a t -> 'b t val map : f:('a -> 'b) -> 'a t -> 'b t
(** [map f a] applies function [f] to all the elements of [a], (** [map f a] applies function [f] to all the elements of [a],
and builds an array with the results returned by [f]: and builds an array with the results returned by [f]:
[[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *) [[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *)
val map2 : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t val map2 : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
(** [map2 f a b] applies function [f] to all the elements of [a] and [b], (** [map2 f a b] applies function [f] to all the elements of [a] and [b],
and builds an array with the results returned by [f]: and builds an array with the results returned by [f]:
[[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]]. [[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]].
@raise Invalid_argument if they have distinct lengths. @raise Invalid_argument if they have distinct lengths.
@since 0.20 *) @since 0.20 *)

View file

@ -22,12 +22,12 @@ val compare : 'a ord -> 'a t ord
val get : 'a t -> int -> 'a val get : 'a t -> int -> 'a
(** [get a n] returns the element number [n] of array [a]. (** [get a n] returns the element number [n] of array [a].
The first element has number 0. The first element has number 0.
The last element has number [length a - 1]. The last element has number [length a - 1].
You can also write [a.(n)] instead of [get a n]. You can also write [a.(n)] instead of [get a n].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [(length a - 1)]. *) if [n] is outside the range 0 to [(length a - 1)]. *)
val get_safe : 'a t -> int -> 'a option val get_safe : 'a t -> int -> 'a option
(** [get_safe a i] returns [Some a.(i)] if [i] is a valid index. (** [get_safe a i] returns [Some a.(i)] if [i] is a valid index.
@ -64,18 +64,18 @@ val sub : 'a t -> int -> int -> 'a t
val set : 'a t -> int -> 'a -> unit val set : 'a t -> int -> 'a -> unit
(** [set a n x] modifies array [a] in place, replacing (** [set a n x] modifies array [a] in place, replacing
element number [n] with [x]. element number [n] with [x].
You can also write [a.(n) <- x] instead of [set a n x]. You can also write [a.(n) <- x] instead of [set a n x].
Raise [Invalid_argument "index out of bounds"] Raise [Invalid_argument "index out of bounds"]
if [n] is outside the range 0 to [length a - 1]. *) if [n] is outside the range 0 to [length a - 1]. *)
val length : _ t -> int val length : _ t -> int
(** Return the length (number of elements) of the given array. *) (** Return the length (number of elements) of the given array. *)
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)], (** [fold f x a] computes [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)],
where [n] is the length of the array [a]. *) where [n] is the length of the array [a]. *)
val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** Fold left on array, with index. *) (** Fold left on array, with index. *)
@ -87,24 +87,24 @@ val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a
val iter : ('a -> unit) -> 'a t -> unit val iter : ('a -> unit) -> 'a t -> unit
(** [iter f a] applies function [f] in turn to all (** [iter f a] applies function [f] in turn to all
the elements of [a]. It is equivalent to the elements of [a]. It is equivalent to
[f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *) [f a.(0); f a.(1); ...; f a.(length a - 1); ()]. *)
val iteri : (int -> 'a -> unit) -> 'a t -> unit val iteri : (int -> 'a -> unit) -> 'a t -> unit
(** Same as {!Array.iter}, but the (** Same as {!Array.iter}, but the
function is applied with the index of the element as first argument, function is applied with the index of the element as first argument,
and the element itself as second argument. *) and the element itself as second argument. *)
val blit : 'a t -> int -> 'a t -> int -> int -> unit val blit : 'a t -> int -> 'a t -> int -> int -> unit
(** [blit v1 o1 v2 o2 len] copies [len] elements (** [blit v1 o1 v2 o2 len] copies [len] elements
from array [v1], starting at element number [o1], to array [v2], from array [v1], starting at element number [o1], to array [v2],
starting at element number [o2]. It works correctly even if starting at element number [o2]. It works correctly even if
[v1] and [v2] are the same array, and the source and [v1] and [v2] are the same array, and the source and
destination chunks overlap. destination chunks overlap.
Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not
designate a valid subarray of [v1], or if [o2] and [len] do not designate a valid subarray of [v1], or if [o2] and [len] do not
designate a valid subarray of [v2]. *) designate a valid subarray of [v2]. *)
val reverse_in_place : 'a t -> unit val reverse_in_place : 'a t -> unit
(** Reverse the array in place. *) (** Reverse the array in place. *)
@ -177,8 +177,8 @@ val bsearch : cmp:('a -> 'a -> int) -> 'a -> 'a t ->
val for_all : ('a -> bool) -> 'a t -> bool val for_all : ('a -> bool) -> 'a t -> bool
(** [for_all p [|a1; ...; an|]] checks if all elements of the array (** [for_all p [|a1; ...; an|]] checks if all elements of the array
satisfy the predicate [p]. That is, it returns satisfy the predicate [p]. That is, it returns
[(p a1) && (p a2) && ... && (p an)]. *) [(p a1) && (p a2) && ... && (p an)]. *)
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** Forall on pairs of arrays. (** Forall on pairs of arrays.

View file

@ -17,12 +17,12 @@ val compare : t -> t -> int
val lowercase_ascii : t -> t val lowercase_ascii : t -> t
(** Convert the given character to its equivalent lowercase character, (** Convert the given character to its equivalent lowercase character,
using the US-ASCII character set. using the US-ASCII character set.
@since 0.20 *) @since 0.20 *)
val uppercase_ascii : t -> t val uppercase_ascii : t -> t
(** Convert the given character to its equivalent uppercase character, (** Convert the given character to its equivalent uppercase character,
using the US-ASCII character set. using the US-ASCII character set.
@since 0.20 *) @since 0.20 *)
val of_int_exn : int -> t val of_int_exn : int -> t

View file

@ -22,12 +22,12 @@ val ( * ) : t -> t -> t
val (/) : t -> t -> t val (/) : t -> t -> t
(** Integer division. Raise [Division_by_zero] if the second (** Integer division. Raise [Division_by_zero] if the second
argument is zero. This division rounds the real quotient of argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for {!Pervasives.(/)}. *) its arguments towards zero, as specified for {!Pervasives.(/)}. *)
val (mod) : t -> t -> t val (mod) : t -> t -> t
(** Integer remainder. (** Integer remainder.
If [y = 0], [x mod y] raises [Division_by_zero]. *) If [y = 0], [x mod y] raises [Division_by_zero]. *)
val abs : t -> t val abs : t -> t
(** Return the absolute value of its argument. *) (** Return the absolute value of its argument. *)
@ -52,29 +52,29 @@ val lnot : t -> t
val (lsl) : t -> int -> t val (lsl) : t -> int -> t
(** [ x lsl y] shifts [x] to the left by [y] bits. (** [ x lsl y] shifts [x] to the left by [y] bits.
The result is unspecified if [y < 0] or [y >= 64]. *) The result is unspecified if [y < 0] or [y >= 64]. *)
val (lsr) : t -> int -> t val (lsr) : t -> int -> t
(** [x lsr y] shifts [x] to the right by [y] bits. (** [x lsr y] shifts [x] to the right by [y] bits.
This is a logical shift: zeroes are inserted in the vacated bits This is a logical shift: zeroes are inserted in the vacated bits
regardless of the sign of [x]. regardless of the sign of [x].
The result is unspecified if [y < 0] or [y >= 64]. *) The result is unspecified if [y < 0] or [y >= 64]. *)
val (asr) : t -> int -> t val (asr) : t -> int -> t
(** [x asr y] shifts [x] to the right by [y] bits. (** [x asr y] shifts [x] to the right by [y] bits.
This is an arithmetic shift: the sign bit of [x] is replicated This is an arithmetic shift: the sign bit of [x] is replicated
and inserted in the vacated bits. and inserted in the vacated bits.
The result is unspecified if [y < 0] or [y >= 64]. *) The result is unspecified if [y < 0] or [y >= 64]. *)
val equal : t -> t -> bool val equal : t -> t -> bool
(** The equal function for int64s. (** The equal function for int64s.
Same as {!Pervasives.(=) x y)}. *) Same as {!Pervasives.(=) x y)}. *)
val compare : t -> t -> int val compare : t -> t -> int
(** The comparison function for 64-bit integers, with the same specification as (** The comparison function for 64-bit integers, with the same specification as
{!Pervasives.compare}. Along with the type [t], this function [compare] {!Pervasives.compare}. Along with the type [t], this function [compare]
allows the module [CCInt64] to be passed as argument to the functors allows the module [CCInt64] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *) {!Set.Make} and {!Map.Make}. *)
val hash : t -> int val hash : t -> int
(** Same as {!Pervasives.abs (to_int x)}. *) (** Same as {!Pervasives.abs (to_int x)}. *)
@ -83,50 +83,50 @@ val hash : t -> int
val to_int : t -> int val to_int : t -> int
(** Convert the given 64-bit integer (type [int64]) to an (** Convert the given 64-bit integer (type [int64]) to an
integer (type [int]). On 64-bit platforms, the 64-bit integer integer (type [int]). On 64-bit platforms, the 64-bit integer
is taken modulo 2{^63}, i.e. the high-order bit is lost is taken modulo 2{^63}, i.e. the high-order bit is lost
during the conversion. On 32-bit platforms, the 64-bit integer during the conversion. On 32-bit platforms, the 64-bit integer
is taken modulo 2{^31}, i.e. the top 33 bits are lost is taken modulo 2{^31}, i.e. the top 33 bits are lost
during the conversion. *) during the conversion. *)
val of_int : int -> t option val of_int : int -> t option
(** Safe version of {!of_int_exn}. *) (** Safe version of {!of_int_exn}. *)
val of_int_exn : int -> t val of_int_exn : int -> t
(** Alias to {!Int64.of_int}. (** Alias to {!Int64.of_int}.
Convert the given integer (type [int]) to a 64-bit integer Convert the given integer (type [int]) to a 64-bit integer
(type [int64]). (type [int64]).
@raise Failure in case of failure. *) @raise Failure in case of failure. *)
val to_int32 : t -> int32 val to_int32 : t -> int32
(** Convert the given 64-bit integer (type [int64]) to a (** Convert the given 64-bit integer (type [int64]) to a
32-bit integer (type [int32]). The 64-bit integer 32-bit integer (type [int32]). The 64-bit integer
is taken modulo 2{^32}, i.e. the top 32 bits are lost is taken modulo 2{^32}, i.e. the top 32 bits are lost
during the conversion. *) during the conversion. *)
val of_int32 : int32 -> t option val of_int32 : int32 -> t option
(** Safe version of {!of_int32_exn}. *) (** Safe version of {!of_int32_exn}. *)
val of_int32_exn : int32 -> t val of_int32_exn : int32 -> t
(** Alias to {!Int64.of_int32} (** Alias to {!Int64.of_int32}
Convert the given 32-bit integer (type [int32]) Convert the given 32-bit integer (type [int32])
to a 64-bit integer (type [int64]). to a 64-bit integer (type [int64]).
@raise Failure in case of failure. *) @raise Failure in case of failure. *)
val to_nativeint : t -> nativeint val to_nativeint : t -> nativeint
(** Convert the given 64-bit integer (type [int64]) to a (** Convert the given 64-bit integer (type [int64]) to a
native integer. On 32-bit platforms, the 64-bit integer native integer. On 32-bit platforms, the 64-bit integer
is taken modulo 2{^32}. On 64-bit platforms, is taken modulo 2{^32}. On 64-bit platforms,
the conversion is exact. *) the conversion is exact. *)
val of_nativeint : nativeint -> t option val of_nativeint : nativeint -> t option
(** Safe version of {!of_nativeint_exn}. *) (** Safe version of {!of_nativeint_exn}. *)
val of_nativeint_exn : nativeint -> t val of_nativeint_exn : nativeint -> t
(** Alias to {!Int64.of_nativeint}. (** Alias to {!Int64.of_nativeint}.
Convert the given native integer (type [nativeint]) Convert the given native integer (type [nativeint])
to a 64-bit integer (type [int64]). to a 64-bit integer (type [int64]).
@raise Failure in case of failure. *) @raise Failure in case of failure. *)
val to_float : t -> float val to_float : t -> float
(** Convert the given 64-bit integer to a floating-point number. *) (** Convert the given 64-bit integer to a floating-point number. *)
@ -136,10 +136,10 @@ val of_float : float -> t option
val of_float_exn : float -> t val of_float_exn : float -> t
(** Alias to {!Int64.of_float}. (** Alias to {!Int64.of_float}.
Convert the given floating-point number to a 64-bit integer, Convert the given floating-point number to a 64-bit integer,
discarding the fractional part (truncate towards 0). discarding the fractional part (truncate towards 0).
The result of the conversion is undefined if, after truncation, The result of the conversion is undefined if, after truncation,
the number is outside the range \[{!CCInt64.min_int}, {!CCInt64.max_int}\]. the number is outside the range \[{!CCInt64.min_int}, {!CCInt64.max_int}\].
@raise Failure in case of failure. *) @raise Failure in case of failure. *)
val to_string : t -> string val to_string : t -> string
@ -150,18 +150,18 @@ val of_string : string -> t option
val of_string_exn : string -> t val of_string_exn : string -> t
(** Alias to {!Int64.of_string}. (** Alias to {!Int64.of_string}.
Convert the given string to a 64-bit integer. Convert the given string to a 64-bit integer.
The string is read in decimal (by default, or if the string The string is read in decimal (by default, or if the string
begins with [0u]) or in hexadecimal, octal or binary if the begins with [0u]) or in hexadecimal, octal or binary if the
string begins with [0x], [0o] or [0b] respectively. string begins with [0x], [0o] or [0b] respectively.
The [0u] prefix reads the input as an unsigned integer in the range The [0u] prefix reads the input as an unsigned integer in the range
[[0, 2*CCInt64.max_int+1]]. If the input exceeds {!CCInt64.max_int} [[0, 2*CCInt64.max_int+1]]. If the input exceeds {!CCInt64.max_int}
it is converted to the signed integer it is converted to the signed integer
[CCInt64.min_int + input - CCInt64.max_int - 1]. [CCInt64.min_int + input - CCInt64.max_int - 1].
The [_] (underscore) character can appear anywhere in the string The [_] (underscore) character can appear anywhere in the string
and is ignored. and is ignored.
Raise [Failure "Int64.of_string"] if the given string is not Raise [Failure "Int64.of_string"] if the given string is not
a valid representation of an integer, or if the integer represented a valid representation of an integer, or if the integer represented
exceeds the range of integers representable in type [int64]. *) exceeds the range of integers representable in type [int64]. *)

View file

@ -1017,7 +1017,7 @@ let uniq ~eq l =
(*$Q (*$Q
Q.(small_list small_int) (fun l -> \ Q.(small_list small_int) (fun l -> \
sort_uniq ~cmp:CCInt.compare l = (uniq ~eq:CCInt.equal l |> sort Pervasives.compare)) sort_uniq ~cmp:CCInt.compare l = (uniq ~eq:CCInt.equal l |> sort Pervasives.compare))
*) *)
let union ~eq l1 l2 = let union ~eq l1 l2 =
let rec union eq acc l1 l2 = match l1 with let rec union eq acc l1 l2 = match l1 with
@ -1065,8 +1065,8 @@ let iteri2 f l1 l2 =
| [], _ | [], _
| _, [] -> invalid_arg "iteri2" | _, [] -> invalid_arg "iteri2"
| x1::l1', x2::l2' -> | x1::l1', x2::l2' ->
f i x1 x2; f i x1 x2;
aux f (i+1) l1' l2' aux f (i+1) l1' l2'
in aux f 0 l1 l2 in aux f 0 l1 l2
let foldi f acc l = let foldi f acc l =

View file

@ -32,7 +32,7 @@ val cons : 'a -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t val append : 'a t -> 'a t -> 'a t
(** Safe version of {!List.append}. (** Safe version of {!List.append}.
Concatenate two lists. *) Concatenate two lists. *)
val cons_maybe : 'a option -> 'a t -> 'a t val cons_maybe : 'a option -> 'a t -> 'a t
(** [cons_maybe (Some x) l] is [x :: l]. (** [cons_maybe (Some x) l] is [x :: l].
@ -41,18 +41,18 @@ val cons_maybe : 'a option -> 'a t -> 'a t
val (@) : 'a t -> 'a t -> 'a t val (@) : 'a t -> 'a t -> 'a t
(** Same as [append]. (** Same as [append].
Concatenate two lists. *) Concatenate two lists. *)
val filter : ('a -> bool) -> 'a t -> 'a t val filter : ('a -> bool) -> 'a t -> 'a t
(** Safe version of {!List.filter}. (** Safe version of {!List.filter}.
[filter p l] returns all the elements of the list [l] [filter p l] returns all the elements of the list [l]
that satisfy the predicate [p]. The order of the elements that satisfy the predicate [p]. The order of the elements
in the input list is preserved. *) in the input list is preserved. *)
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
(** Safe version of [fold_right]. (** Safe version of [fold_right].
[fold_right f [a1; ...; an] b] is [fold_right f [a1; ...; an] b] is
[f a1 (f a2 (... (f an b) ...))]. Not tail-recursive. *) [f a1 (f a2 (... (f an b) ...))]. Not tail-recursive. *)
val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a
(** Fold until a stop condition via [('a, `Stop)] is (** Fold until a stop condition via [('a, `Stop)] is
@ -95,9 +95,9 @@ val init : int -> (int -> 'a) -> 'a t
val combine : 'a list -> 'b list -> ('a * 'b) list val combine : 'a list -> 'b list -> ('a * 'b) list
(** Similar to {!List.combine} but tail-recursive. (** Similar to {!List.combine} but tail-recursive.
Transform a pair of lists into a list of pairs: Transform a pair of lists into a list of pairs:
[combine [a1; ...; an] [b1; ...; bn]] is [combine [a1; ...; an] [b1; ...; bn]] is
[[(a1,b1); ...; (an,bn)]]. [[(a1,b1); ...; (an,bn)]].
@raise Invalid_argument if the lists have distinct lengths. @raise Invalid_argument if the lists have distinct lengths.
@since 1.2 *) @since 1.2 *)
@ -110,20 +110,20 @@ val combine_gen : 'a list -> 'b list -> ('a * 'b) gen
val split : ('a * 'b) t -> 'a t * 'b t val split : ('a * 'b) t -> 'a t * 'b t
(** A tail-recursive version of {!List.split}. (** A tail-recursive version of {!List.split}.
Transform a list of pairs into a pair of lists: Transform a list of pairs into a pair of lists:
[split [(a1,b1); ...; (an,bn)]] is [([a1; ...; an], [b1; ...; bn])]. *) [split [(a1,b1); ...; (an,bn)]] is [([a1; ...; an], [b1; ...; bn])]. *)
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val compare_lengths : 'a t -> 'b t -> int val compare_lengths : 'a t -> 'b t -> int
(** Equivalent to [compare (length l1) (length l2)] but more efficient. (** Equivalent to [compare (length l1) (length l2)] but more efficient.
Compare the lengths of two lists. Compare the lengths of two lists.
@since 1.5 *) @since 1.5 *)
val compare_length_with : 'a t -> int -> int val compare_length_with : 'a t -> int -> int
(** Equivalent to [compare (length l) x] but more efficient. (** Equivalent to [compare (length l) x] but more efficient.
Compare the length of a list to an integer. Compare the length of a list to an integer.
@since 1.5 *) @since 1.5 *)
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
@ -144,13 +144,13 @@ val cartesian_product : 'a t t -> 'a t t
by returning all the ways of picking one element per sublist. by returning all the ways of picking one element per sublist.
{b NOTE} the order of the returned list is unspecified. {b NOTE} the order of the returned list is unspecified.
For example: For example:
{[ {[
# cartesian_product [[1;2];[3];[4;5;6]] |> sort = # cartesian_product [[1;2];[3];[4;5;6]] |> sort =
[[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];; [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
# cartesian_product [[1;2];[];[4;5;6]] = [];; # cartesian_product [[1;2];[];[4;5;6]] = [];;
# cartesian_product [[1;2];[3];[4];[5];[6]] |> sort = # cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
[[1;3;4;5;6];[2;3;4;5;6]];; [[1;3;4;5;6];[2;3;4;5;6]];;
]} ]}
invariant: [cartesian_product l = map_product id l]. invariant: [cartesian_product l = map_product id l].
@since 1.2 *) @since 1.2 *)
@ -353,13 +353,13 @@ val group_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list list
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
(** Same as {!map}, but the function is applied to the index of (** Same as {!map}, but the function is applied to the index of
the element as first argument (counting from 0), and the element the element as first argument (counting from 0), and the element
itself as second argument. *) itself as second argument. *)
val iteri : (int -> 'a -> unit) -> 'a t -> unit val iteri : (int -> 'a -> unit) -> 'a t -> unit
(** Same as {!iter}, but the function is applied to the index of (** Same as {!iter}, but the function is applied to the index of
the element as first argument (counting from 0), and the element the element as first argument (counting from 0), and the element
itself as second argument. *) itself as second argument. *)
val iteri2 : (int -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit val iteri2 : (int -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit
(** @raise Invalid_argument when lists do not have the same length. (** @raise Invalid_argument when lists do not have the same length.

View file

@ -26,7 +26,7 @@ val cons : 'a -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t val append : 'a t -> 'a t -> 'a t
(** Safe version of {!List.append}. (** Safe version of {!List.append}.
Concatenate two lists. *) Concatenate two lists. *)
val cons_maybe : 'a option -> 'a t -> 'a t val cons_maybe : 'a option -> 'a t -> 'a t
(** [cons_maybe (Some x) l] is [x :: l]. (** [cons_maybe (Some x) l] is [x :: l].
@ -35,7 +35,7 @@ val cons_maybe : 'a option -> 'a t -> 'a t
val (@) : 'a t -> 'a t -> 'a t val (@) : 'a t -> 'a t -> 'a t
(** Same as [append]. (** Same as [append].
Concatenate two lists. *) Concatenate two lists. *)
val filter : f:('a -> bool) -> 'a t -> 'a t val filter : f:('a -> bool) -> 'a t -> 'a t
(** Safe version of {!List.filter}. *) (** Safe version of {!List.filter}. *)
@ -240,13 +240,13 @@ val group_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list list
val mapi : f:(int -> 'a -> 'b) -> 'a t -> 'b t val mapi : f:(int -> 'a -> 'b) -> 'a t -> 'b t
(** Same as {!map}, but the function is applied to the index of (** Same as {!map}, but the function is applied to the index of
the element as first argument (counting from 0), and the element the element as first argument (counting from 0), and the element
itself as second argument. *) itself as second argument. *)
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit val iteri : f:(int -> 'a -> unit) -> 'a t -> unit
(** Same as {!iter}, but the function is applied to the index of (** Same as {!iter}, but the function is applied to the index of
the element as first argument (counting from 0), and the element the element as first argument (counting from 0), and the element
itself as second argument. *) itself as second argument. *)
val foldi : f:('b -> int -> 'a -> 'b) -> init:'b -> 'a t -> 'b val foldi : f:('b -> int -> 'a -> 'b) -> init:'b -> 'a t -> 'b
(** Fold on list, with index. *) (** Fold on list, with index. *)

View file

@ -775,7 +775,7 @@ let exists2 p s1 s2 =
try iter2 (fun c1 c2 -> if p c1 c2 then raise MyExit) s1 s2; false try iter2 (fun c1 c2 -> if p c1 c2 then raise MyExit) s1 s2; false
with MyExit -> true with MyExit -> true
(** {2 Ascii functions} *) (** {2 Ascii functions} *)
let equal_caseless s1 s2: bool = let equal_caseless s1 s2: bool =
String.length s1 = String.length s2 && String.length s1 = String.length s2 &&

View file

@ -128,7 +128,7 @@ module type S = sig
val pp : key printer -> 'a printer -> 'a t printer val pp : key printer -> 'a printer -> 'a t printer
(** Renamed from [val print]. (** Renamed from [val print].
@since NEXT_RELEASE *) @since NEXT_RELEASE *)
(**/**) (**/**)
val node_ : key -> 'a -> 'a t -> 'a t -> 'a t val node_ : key -> 'a -> 'a t -> 'a t -> 'a t

View file

@ -1,13 +1,13 @@
let () = let () =
let major, minor = let major, minor =
Scanf.sscanf Sys.ocaml_version "%u.%u" Scanf.sscanf Sys.ocaml_version "%u.%u"
(fun major minor -> major, minor) (fun major minor -> major, minor)
in in
let after_4_3 = (major, minor) >= (4, 3) in let after_4_3 = (major, minor) >= (4, 3) in
let flags_file = open_out "flambda.flags" in let flags_file = open_out "flambda.flags" in
if after_4_3 then ( if after_4_3 then (
output_string flags_file "(-O3 -unbox-closures -unbox-closures-factor 20 -color always)\n"; output_string flags_file "(-O3 -unbox-closures -unbox-closures-factor 20 -color always)\n";
) else ( ) else (
output_string flags_file "()\n"; output_string flags_file "()\n";
); );
close_out flags_file close_out flags_file

View file

@ -146,8 +146,8 @@ module Make(P : PARAM) = struct
Condition.broadcast pool.cond; (* wake up some worker, if any *) Condition.broadcast pool.cond; (* wake up some worker, if any *)
(* might want to process in the background, if all threads are busy *) (* might want to process in the background, if all threads are busy *)
if not (Queue.is_empty pool.jobs) if not (Queue.is_empty pool.jobs)
&& pool.cur_idle = 0 && pool.cur_idle = 0
&& can_start_thread_ pool then ( && can_start_thread_ pool then (
launch_worker_ pool; launch_worker_ pool;
) )
)) ))