... tweaks

This commit is contained in:
JPR 2020-06-28 20:54:50 +02:00
parent 89300a1314
commit c6181309fb
14 changed files with 49 additions and 49 deletions

View file

@ -474,7 +474,7 @@ let swap a i j =
a=b) a=b)
*) *)
(* shuffle a[i...j[ using the given int random generator (* shuffle a[i … j] using the given int random generator
See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle *) See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle *)
let _shuffle _rand_int a i j = let _shuffle _rand_int a i j =
for k = j-1 downto i+1 do for k = j-1 downto i+1 do

View file

@ -36,7 +36,7 @@ val get_safe : 'a t -> int -> 'a option
@since 0.18 *) @since 0.18 *)
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** [fold f init a] computes [f (... (f (f init a.(0)) a.(1)) ...) a.(n-1)], (** [fold f init a] computes [f ( (f (f init 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].
Same as {!Array.fold_left}*) Same as {!Array.fold_left}*)
@ -143,18 +143,18 @@ val bsearch : cmp:('a -> 'a -> int) -> 'a -> 'a t ->
@since 0.13 *) @since 0.13 *)
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** [for_all2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if each pair of elements [ai bi] (** [for_all2 f [|a1; …; an|] [|b1; …; bn|]] is [true] if each pair of elements [ai bi]
satisfies the predicate [f]. satisfies the predicate [f].
That is, it returns [(f a1 b1) && (f a2 b2) && ... && (f an bn)]. That is, it returns [(f a1 b1) && (f a2 b2) && && (f an bn)].
@raise Invalid_argument if arrays have distinct lengths. @raise Invalid_argument if arrays have distinct lengths.
Allow different types. Allow different types.
@since 0.20 *) @since 0.20 *)
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** [exists2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if any pair of elements [ai bi] (** [exists2 f [|a1; …; an|] [|b1; …; bn|]] is [true] if any pair of elements [ai bi]
satisfies the predicate [f]. satisfies the predicate [f].
That is, it returns [(f a1 b1) || (f a2 b2) || ... || (f an bn)]. That is, it returns [(f a1 b1) || (f a2 b2) || || (f an bn)].
@raise Invalid_argument if arrays have distinct lengths. @raise Invalid_argument if arrays have distinct lengths.
Allow different types. Allow different types.
@ -162,7 +162,7 @@ val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc
(** [fold2 f init a b] fold on two arrays [a] and [b] stepwise. (** [fold2 f init a b] fold on two arrays [a] and [b] stepwise.
It computes [f (... (f init a1 b1)...) an bn]. It computes [f ( (f init a1 b1) ) an bn].
@raise Invalid_argument if [a] and [b] have distinct lengths. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @since 0.20 *)
@ -220,7 +220,7 @@ val filter : ('a -> bool) -> 'a t -> 'a t
the given predicate [f] will be kept. *) the given predicate [f] will be kept. *)
val filter_map : ('a -> 'b option) -> 'a t -> 'b t val filter_map : ('a -> 'b option) -> 'a t -> 'b t
(** [filter_map f [|a1; ...; an|]] calls [(f a1) ... (f an)] and returns an array [b] consisting (** [filter_map f [|a1; …; an|]] calls [(f a1) (f an)] and returns an array [b] consisting
of all elements [bi] such as [f ai = Some bi]. When [f] returns [None], the corresponding of all elements [bi] such as [f ai = Some bi]. When [f] returns [None], the corresponding
element of [a] is discarded. *) element of [a] is discarded. *)

View file

@ -35,7 +35,7 @@ val get_safe : 'a t -> int -> 'a option
@since 0.18 *) @since 0.18 *)
val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a
(** [fold ~f ~init a] computes [f ( (f (f init a.(0)) a.(1)) ) a.(n-1)], (** [fold ~f ~init a] computes [f ( (f (f init 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].
Same as {!ArrayLabels.fold_left} *) Same as {!ArrayLabels.fold_left} *)
@ -142,18 +142,18 @@ val bsearch : cmp:(('a -> 'a -> int) [@keep_label]) -> key:'a -> 'a t ->
@since 0.13 *) @since 0.13 *)
val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** [for_all2 ~f [|a1; ⋯; an|] [|b1; ⋯; bn|]] is [true] if each pair of elements [ai bi] (** [for_all2 ~f [|a1; …; an|] [|b1; …; bn|]] is [true] if each pair of elements [ai bi]
satisfies the predicate [f]. satisfies the predicate [f].
That is, it returns [(f a1 b1) && (f a2 b2) && && (f an bn)]. That is, it returns [(f a1 b1) && (f a2 b2) && && (f an bn)].
@raise Invalid_argument if arrays have distinct lengths. @raise Invalid_argument if arrays have distinct lengths.
Allow different types. Allow different types.
@since 0.20 *) @since 0.20 *)
val exists2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool val exists2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
(** [exists2 ~f [|a1; ⋯; an|] [|b1; ⋯; bn|]] is [true] if any pair of elements [ai bi] (** [exists2 ~f [|a1; …; an|] [|b1; …; bn|]] is [true] if any pair of elements [ai bi]
satisfies the predicate [f]. satisfies the predicate [f].
That is, it returns [(f a1 b1) || (f a2 b2) || || (f an bn)]. That is, it returns [(f a1 b1) || (f a2 b2) || || (f an bn)].
@raise Invalid_argument if arrays have distinct lengths. @raise Invalid_argument if arrays have distinct lengths.
Allow different types. Allow different types.
@ -161,14 +161,14 @@ val exists2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val fold2 : f:('acc -> 'a -> 'b -> 'acc) -> init:'acc -> 'a t -> 'b t -> 'acc val fold2 : f:('acc -> 'a -> 'b -> 'acc) -> init:'acc -> 'a t -> 'b t -> 'acc
(** [fold2 ~f ~init a b] fold on two arrays [a] and [b] stepwise. (** [fold2 ~f ~init a b] fold on two arrays [a] and [b] stepwise.
It computes [f ((f init a1 b1)) an bn]. It computes [f ((f init a1 b1) ) an bn].
@raise Invalid_argument if [a] and [b] have distinct lengths. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @since 0.20 *)
val iter2 : f:('a -> 'b -> unit) -> 'a t -> 'b t -> unit val iter2 : f:('a -> 'b -> unit) -> 'a t -> 'b t -> unit
(** [iter2 ~f a b] iterates on the two arrays [a] and [b] stepwise. (** [iter2 ~f a b] iterates on the two arrays [a] and [b] stepwise.
It is equivalent to [f a0 b0; ; f a.(length a - 1) b.(length b - 1); ()]. It is equivalent to [f a0 b0; ; f a.(length a - 1) b.(length b - 1); ()].
@raise Invalid_argument if [a] and [b] have distinct lengths. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @since 0.20 *)
@ -220,7 +220,7 @@ val pp_i: ?sep:string -> (int -> 'a printer) -> 'a t printer
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 elements of [a] and [b], (** [map2 ~f a b] applies function [f] to all 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 [a] and [b] have distinct lengths. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @since 0.20 *)
@ -235,7 +235,7 @@ val filter : f:('a -> bool) -> 'a t -> 'a t
the given predicate [f] will be kept. *) the given predicate [f] will be kept. *)
val filter_map : f:('a -> 'b option) -> 'a t -> 'b t val filter_map : f:('a -> 'b option) -> 'a t -> 'b t
(** [filter_map ~f [|a1; ⋯; an|]] calls [(f a1) (f an)] and returns an array [b] consisting (** [filter_map ~f [|a1; …; an|]] calls [(f a1) (f an)] and returns an array [b] consisting
of all elements [bi] such as [f ai = Some bi]. When [f] returns [None], the corresponding of all elements [bi] such as [f ai = Some bi]. When [f] returns [None], the corresponding
element of [a] is discarded. *) element of [a] is discarded. *)

View file

@ -15,7 +15,7 @@ val compare : t -> t -> int
val of_int_exn : int -> t val of_int_exn : int -> t
(** Alias to {!Char.chr}. (** Alias to {!Char.chr}.
Return the character with the given ASCII code. Return the character with the given ASCII code.
@raise Invalid_argument if the int is not within [0,...,255]. @raise Invalid_argument if the int is not within [0 255].
@since 1.0 *) @since 1.0 *)
val of_int : int -> t option val of_int : int -> t option

View file

@ -293,7 +293,7 @@ let mark_close_tag st ~or_else s =
| _ -> | _ ->
let style = let style =
try try
ignore (Stack.pop st); (* pop current style (if well-scoped...) *) ignore (Stack.pop st); (* pop current style (if well-scoped) *)
Stack.top st (* look at previous style *) Stack.top st (* look at previous style *)
with Stack.Empty -> with Stack.Empty ->
[`Reset] [`Reset]

View file

@ -27,7 +27,7 @@ val int32 : int32 t
val int64 : int64 t val int64 : int64 t
val nativeint : nativeint t val nativeint : nativeint t
val slice : string -> int -> int t val slice : string -> int -> int t
(** [slice s i len state] hashes the slice [i, ... i+len-1] of [s] (** [slice s i len state] hashes the slice [i, …, i+len-1] of [s]
into [state]. *) into [state]. *)
val string : string t val string : string t

View file

@ -24,7 +24,7 @@ val is_empty : _ t -> bool
@since 0.11 *) @since 0.11 *)
val map : ('a -> 'b) -> 'a t -> 'b t val map : ('a -> 'b) -> 'a t -> 'b t
(** [map f [a0; a1; ⋯ an]] applies function [f] in turn to [a0; a1; ⋯ an]. (** [map f [a0; a1; …; an]] applies function [f] in turn to [a0; a1; …; an].
Safe version of {!List.map}. *) Safe version of {!List.map}. *)
val (>|=) : 'a t -> ('a -> 'b) -> 'b t val (>|=) : 'a t -> ('a -> 'b) -> 'b t
@ -51,8 +51,8 @@ val filter : ('a -> bool) -> 'a t -> 'a t
Safe version of {!List.filter}. *) Safe version of {!List.filter}. *)
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
(** [fold_right f [a1; an] b] is (** [fold_right f [a1; …; an] b] is
[f a1 (f a2 ( (f an b) ))]. [f a1 (f a2 ( (f an b) ))].
Safe version of {!List.fold_right}. *) Safe version of {!List.fold_right}. *)
val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a
@ -76,7 +76,7 @@ val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> 'acc -> 'a list
@since 2.8 *) @since 2.8 *)
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list
(** [scan_left f init l] returns the list [[init; f init x0; f (f init x0) x1; ]] (** [scan_left f init l] returns the list [[init; f init x0; f (f init x0) x1; ]]
where [x0], [x1], etc. are the elements of [l]. where [x0], [x1], etc. are the elements of [l].
@since 1.2, but only @since 1.2, but only
@since 2.2 with labels *) @since 2.2 with labels *)
@ -117,12 +117,12 @@ val count_true_false : ('a -> bool) -> 'a list -> int * int
@since 2.4 *) @since 2.4 *)
val init : int -> (int -> 'a) -> 'a t val init : int -> (int -> 'a) -> 'a t
(** [init len f] is [f 0; f 1; ; f (len-1)]. (** [init len f] is [f 0; f 1; ; f (len-1)].
@raise Invalid_argument if len < 0. @raise Invalid_argument if len < 0.
@since 0.6 *) @since 0.6 *)
val combine : 'a list -> 'b list -> ('a * 'b) list val combine : 'a list -> 'b list -> ('a * 'b) list
(** [combine [a1; ⋯; an] [b1; ⋯; bn]] is [[(a1,b1); ⋯; (an,bn)]]. (** [combine [a1; …; an] [b1; …; bn]] is [[(a1,b1); …; (an,bn)]].
Transform two lists into a list of pairs. Transform two lists into a list of pairs.
Like {!List.combine} but tail-recursive. Like {!List.combine} but tail-recursive.
@raise Invalid_argument if the lists have distinct lengths. @raise Invalid_argument if the lists have distinct lengths.
@ -139,7 +139,7 @@ val combine_gen : 'a list -> 'b list -> ('a * 'b) gen
@since 2.2 with labels *) @since 2.2 with labels *)
val split : ('a * 'b) t -> 'a t * 'b t val split : ('a * 'b) t -> 'a t * 'b t
(** [split [(a1,b1); ⋯; (an,bn)]] is [([a1; ⋯; an], [b1; ⋯; bn])]. (** [split [(a1,b1); …; (an,bn)]] is [([a1; …; an], [b1; …; bn])].
Transform a list of pairs into a pair of lists. Transform a list of pairs into a pair of lists.
A tail-recursive version of {!List.split}. A tail-recursive version of {!List.split}.
@since 1.2, but only @since 1.2, but only
@ -173,7 +173,7 @@ val flat_map_i : (int -> 'a -> 'b t) -> 'a t -> 'b t
@since 2.8 *) @since 2.8 *)
val flatten : 'a t t -> 'a t val flatten : 'a t t -> 'a t
(** [flatten [l1]; [l2]; ] concatenates a list of lists. (** [flatten [l1]; [l2]; ] concatenates a list of lists.
Safe version of {!List.flatten}. *) Safe version of {!List.flatten}. *)
val product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t val product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
@ -184,7 +184,7 @@ val fold_product : ('c -> 'a -> 'b -> 'c) -> 'c -> 'a t -> 'b t -> 'c
the pair of elements of [l1] and [l2]. Fold on the cartesian product. *) the pair of elements of [l1] and [l2]. Fold on the cartesian product. *)
val cartesian_product : 'a t t -> 'a t t val cartesian_product : 'a t t -> 'a t t
(** [cartesian_product [[l1];[l2]; ⋯[ln]]] produces the cartesian product of this list of lists, (** [cartesian_product [[l1]; [l2]; …; [ln]]] produces the cartesian product of this list of lists,
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:
@ -202,7 +202,7 @@ val cartesian_product : 'a t t -> 'a t t
val map_product_l : ('a -> 'b list) -> 'a list -> 'b list list val map_product_l : ('a -> 'b list) -> 'a list -> 'b list list
(** [map_product_l f l] maps each element of [l] to a list of (** [map_product_l f l] maps each element of [l] to a list of
objects of type ['b] using [f]. objects of type ['b] using [f].
We obtain [[l1;l2;;ln]] where [length l=n] and [li : 'b list]. We obtain [[l1; l2; ; ln]] where [length l=n] and [li : 'b list].
Then, it returns all the ways of picking exactly one element per [li]. Then, it returns all the ways of picking exactly one element per [li].
@since 1.2, but only @since 1.2, but only
@since 2.2 with labels *) @since 2.2 with labels *)

View file

@ -24,7 +24,7 @@ val is_empty : _ t -> bool
@since 0.11 *) @since 0.11 *)
val map : f:('a -> 'b) -> 'a t -> 'b t val map : f:('a -> 'b) -> 'a t -> 'b t
(** [map ~f [a0; a1; ⋯ an]] applies function [f] in turn to [[a0; a1; ⋯ an]]. (** [map ~f [a0; a1; …; an]] applies function [f] in turn to [[a0; a1; …; an]].
Safe version of {!List.map}. *) Safe version of {!List.map}. *)
val (>|=) : 'a t -> ('a -> 'b) -> 'b t val (>|=) : 'a t -> ('a -> 'b) -> 'b t
@ -55,8 +55,8 @@ val filter : f:('a -> bool) -> 'a t -> 'a t
Safe version of {!List.filter}. *) Safe version of {!List.filter}. *)
val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b
(** [fold_right ~f [a1; an] ~init] is (** [fold_right ~f [a1; …; an] ~init] is
[f a1 (f a2 ( (f an init) ))]. [f a1 (f a2 ( (f an init) ))].
Safe version of {!List.fold_right}. *) Safe version of {!List.fold_right}. *)
val fold_while : f:('a -> 'b -> 'a * [`Stop | `Continue]) -> init:'a -> 'b t -> 'a val fold_while : f:('a -> 'b -> 'a * [`Stop | `Continue]) -> init:'a -> 'b t -> 'a
@ -80,7 +80,7 @@ val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> init:'acc -> 'a
@since 2.8 *) @since 2.8 *)
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list
(** [scan_left ~f ~init l] returns the list [[init; f init x0; f (f init x0) x1; ]] (** [scan_left ~f ~init l] returns the list [[init; f init x0; f (f init x0) x1; ]]
where [x0], [x1], etc. are the elements of [l]. where [x0], [x1], etc. are the elements of [l].
@since 1.2, but only @since 1.2, but only
@since 2.2 with labels *) @since 2.2 with labels *)
@ -121,12 +121,12 @@ val count_true_false : f:('a -> bool) -> 'a list -> int * int
@since 2.4 *) @since 2.4 *)
val init : int -> f:(int -> 'a) -> 'a t val init : int -> f:(int -> 'a) -> 'a t
(** [init len ~f] is [f 0; f 1; ; f (len-1)]. (** [init len ~f] is [f 0; f 1; ; f (len-1)].
@raise Invalid_argument if len < 0. @raise Invalid_argument if len < 0.
@since 0.6 *) @since 0.6 *)
val combine : 'a list -> 'b list -> ('a * 'b) list val combine : 'a list -> 'b list -> ('a * 'b) list
(** [combine [a1; ⋯; an] [b1; ⋯; bn]] is [[(a1,b1); ⋯; (an,bn)]]. (** [combine [a1; …; an] [b1; …; bn]] is [[(a1,b1); …; (an,bn)]].
Transform two lists into a list of pairs. Transform two lists into a list of pairs.
Like {!List.combine} but tail-recursive. Like {!List.combine} but tail-recursive.
@raise Invalid_argument if the lists have distinct lengths. @raise Invalid_argument if the lists have distinct lengths.
@ -143,7 +143,7 @@ val combine_gen : 'a list -> 'b list -> ('a * 'b) gen
@since 2.2 with labels *) @since 2.2 with labels *)
val split : ('a * 'b) t -> 'a t * 'b t val split : ('a * 'b) t -> 'a t * 'b t
(** [split [(a1,b1); ⋯; (an,bn)]] is [([a1; ⋯; an], [b1; ⋯; bn])]. (** [split [(a1,b1); …; (an,bn)]] is [([a1; …; an], [b1; …; bn])].
Transform a list of pairs into a pair of lists. Transform a list of pairs into a pair of lists.
A tail-recursive version of {!List.split}. A tail-recursive version of {!List.split}.
@since 1.2, but only @since 1.2, but only
@ -177,7 +177,7 @@ val flat_map_i : f:(int -> 'a -> 'b t) -> 'a t -> 'b t
@since 2.8 *) @since 2.8 *)
val flatten : 'a t t -> 'a t val flatten : 'a t t -> 'a t
(** [flatten [l1]; [l2]; ] concatenates a list of lists. (** [flatten [l1]; [l2]; ] concatenates a list of lists.
Safe version of {!List.flatten}. *) Safe version of {!List.flatten}. *)
val product : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t val product : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
@ -188,7 +188,7 @@ val fold_product : f:('c -> 'a -> 'b -> 'c) -> init:'c -> 'a t -> 'b t -> 'c
the pair of elements of [l1] and [l2]. Fold on the cartesian product. *) the pair of elements of [l1] and [l2]. Fold on the cartesian product. *)
val cartesian_product : 'a t t -> 'a t t val cartesian_product : 'a t t -> 'a t t
(** [cartesian_product [[l1];[l2]; [ln]]] produces the cartesian product of this list of lists, (** [cartesian_product [[l1];[l2]; …; [ln]]] produces the cartesian product of this list of lists,
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:
@ -206,7 +206,7 @@ val cartesian_product : 'a t t -> 'a t t
val map_product_l : f:('a -> 'b list) -> 'a list -> 'b list list val map_product_l : f:('a -> 'b list) -> 'a list -> 'b list list
(** [map_product_l ~f l] maps each element of [l] to a list of (** [map_product_l ~f l] maps each element of [l] to a list of
objects of type ['b] using [f]. objects of type ['b] using [f].
We obtain [[l1;l2;;ln]] where [length l=n] and [li : 'b list]. We obtain [[l1; l2; ; ln]] where [length l=n] and [li : 'b list].
Then, it returns all the ways of picking exactly one element per [li]. Then, it returns all the ways of picking exactly one element per [li].
@since 1.2, but only @since 1.2, but only
@since 2.2 with labels *) @since 2.2 with labels *)

View file

@ -96,7 +96,7 @@ val get_lazy : (unit -> 'a) -> 'a t -> 'a
@since 0.6.1 *) @since 0.6.1 *)
val sequence_l : 'a t list -> 'a list t val sequence_l : 'a t list -> 'a list t
(** [sequence_l [x1; x2; ⋯; xn]] returns [Some [y1; y2; ⋯;yn]] if (** [sequence_l [x1; x2; …; xn]] returns [Some [y1; y2; …; yn]] if
every [xi] is [Some yi]. Otherwise, if the list contains at least every [xi] is [Some yi]. Otherwise, if the list contains at least
one [None], the result is [None]. *) one [None], the result is [None]. *)

View file

@ -113,8 +113,8 @@ let _diff_list ~last l =
(* Partition of an int into [len] integers uniformly. (* Partition of an int into [len] integers uniformly.
We first sample (len-1) points from the set {1,..i-1} without replacement. We first sample (len-1) points from the set {1,..i-1} without replacement.
We sort these points and add back 0 and i, we have thus We sort these points and add back 0 and i, we have thus
x_0 = 0 < x_1 < x_2 < ... < x_{len-1} < i = x_{len}. x_0 = 0 < x_1 < x_2 < < x_{len-1} < i = x_{len}.
If we define, y_k = x_{k+1} - x_{k} for k in 0..(len-1), then by construction If we define, y_k = x_{k+1} - x_{k} for k in 0 (len-1), then by construction
_k y_k = _k (x_{k+1} - x_k ) = x_{len} - x_0 = i. *) _k y_k = _k (x_{k+1} - x_k ) = x_{len} - x_0 = i. *)
let split_list i ~len st = let split_list i ~len st =
if len <= 1 then invalid_arg "Random.split_list"; if len <= 1 then invalid_arg "Random.split_list";

View file

@ -215,7 +215,7 @@ val flatten_l : ('a, 'err) t list -> ('a list, 'err) t
*) *)
val map_l : ('a -> ('b, 'err) t) -> 'a list -> ('b list, 'err) t val map_l : ('a -> ('b, 'err) t) -> 'a list -> ('b list, 'err) t
(** [map_l f [a1; ...; an]] applies the function [f] to [a1, ..., an] , and, in case of (** [map_l f [a1; …; an]] applies the function [f] to [a1, …, an] ,and, in case of
success for every element, returns the list of [Ok]-value. success for every element, returns the list of [Ok]-value.
Otherwise, it fails and returns the first error encountered. Tail-recursive.*) Otherwise, it fails and returns the first error encountered. Tail-recursive.*)

View file

@ -295,7 +295,7 @@ let rfind ~sub =
i < 0 || String.sub s1 i (length s2) = s2) i < 0 || String.sub s1 i (length s2) = s2)
*) *)
(* Replace substring [s.[pos]....s.[pos+len-1]] by [by] in [s] *) (* Replace substring [s.[pos]s.[pos+len-1]] by [by] in [s] *)
let replace_at_ ~pos ~len ~by s = let replace_at_ ~pos ~len ~by s =
let b = Buffer.create (length s + length by - len) in let b = Buffer.create (length s + length by - len) in
Buffer.add_substring b s 0 pos; Buffer.add_substring b s 0 pos;

View file

@ -26,7 +26,7 @@ val blit : t -> int -> Bytes.t -> int -> int -> unit
val blit_immut : t -> int -> t -> int -> int -> string val blit_immut : t -> int -> t -> int -> int -> string
(** Immutable version of {!blit}, returning a new string. (** Immutable version of {!blit}, returning a new string.
[blit a i b j len] is the same as [b], but in which [blit a i b j len] is the same as [b], but in which
the range [j, ..., j+len] is replaced by [a.[i], ..., a.[i + len]]. the range [j, , j+len] is replaced by [a.[i], , a.[i + len]].
@raise Invalid_argument if indices are not valid. *) @raise Invalid_argument if indices are not valid. *)
*) *)
@ -205,7 +205,7 @@ val iter : (char -> unit) -> string -> unit
@since 0.12 *) @since 0.12 *)
val filter_map : (char -> char option) -> string -> string val filter_map : (char -> char option) -> string -> string
(** [filter_map f s] calls [(f a0) (f a1) ... (f an)] where [a0 ... an] are the characters of s. (** [filter_map f s] calls [(f a0) (f a1) (f an)] where [a0 … an] are the characters of s.
It returns the string of characters [ci] such as [f ai = Some ci] (when [f] returns [None], It returns the string of characters [ci] such as [f ai = Some ci] (when [f] returns [None],
the corresponding element of [s] is discarded). the corresponding element of [s] is discarded).
@since 0.17 *) @since 0.17 *)

View file

@ -24,7 +24,7 @@ val blit : src:t -> src_pos:int -> dst:Bytes.t -> dst_pos:int -> len:int -> unit
val blit_immut : t -> int -> t -> int -> int -> string val blit_immut : t -> int -> t -> int -> int -> string
(** Immutable version of {!blit}, returning a new string. (** Immutable version of {!blit}, returning a new string.
[blit a i b j len] is the same as [b], but in which [blit a i b j len] is the same as [b], but in which
the range [j, ..., j+len] is replaced by [a.[i], ..., a.[i + len]]. the range [j, , j+len] is replaced by [a.[i], , a.[i + len]].
@raise Invalid_argument if indices are not valid. *) @raise Invalid_argument if indices are not valid. *)
*) *)
@ -208,7 +208,7 @@ val iter : f:(char -> unit) -> string -> unit
@since 0.12 *) @since 0.12 *)
val filter_map : f:(char -> char option) -> string -> string val filter_map : f:(char -> char option) -> string -> string
(** [filter_map f s] calls [(f a0) (f a1) ... (f an)] where [a0 ... an] are the characters of s. (** [filter_map f s] calls [(f a0) (f a1) (f an)] where [a0 … an] are the characters of s.
It returns the string of characters [ci] such as [f ai = Some ci] (when [f] returns [None], It returns the string of characters [ci] such as [f ai = Some ci] (when [f] returns [None],
the corresponding element of [s] is discarded). the corresponding element of [s] is discarded).
@since 0.17 *) @since 0.17 *)