mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-10 13:13:56 -05:00
breaking: make Array.random_choose raise invalid_arg instead of not_found
This commit is contained in:
parent
f190964cfd
commit
bfa5d9adde
2 changed files with 2 additions and 2 deletions
|
|
@ -517,7 +517,7 @@ let rec _to_klist a i j () =
|
||||||
|
|
||||||
let random_choose a =
|
let random_choose a =
|
||||||
let n = Array.length a in
|
let n = Array.length a in
|
||||||
if n = 0 then raise Not_found;
|
if n = 0 then invalid_arg "Array.random_choose";
|
||||||
fun st -> a.(Random.State.int st n)
|
fun st -> a.(Random.State.int st n)
|
||||||
|
|
||||||
let random_len n g st =
|
let random_len n g st =
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ val shuffle_with : Random.State.t -> 'a t -> unit
|
||||||
|
|
||||||
val random_choose : 'a t -> 'a random_gen
|
val random_choose : 'a t -> 'a random_gen
|
||||||
(** [random_choose a rs] randomly chooses an element of [a].
|
(** [random_choose a rs] randomly chooses an element of [a].
|
||||||
@raise Not_found if the array/slice is empty. *)
|
@raise Invalid_argument if the array/slice is empty. *)
|
||||||
|
|
||||||
val to_seq : 'a t -> 'a sequence
|
val to_seq : 'a t -> 'a sequence
|
||||||
(** [to_seq a] returns a [sequence] of the elements of an array [a].
|
(** [to_seq a] returns a [sequence] of the elements of an array [a].
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue