breaking: make Array.random_choose raise invalid_arg instead of not_found

This commit is contained in:
Simon Cruanes 2019-02-19 18:46:08 -06:00
parent f190964cfd
commit bfa5d9adde
2 changed files with 2 additions and 2 deletions

View file

@ -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 =

View file

@ -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].