SHOW:
|
|
- or go back to the newest paste.
1 | type 'a nums = Int : int nums | Float : float nums | |
2 | ||
3 | let random_array = | |
4 | fun (type t) n (num_t : t nums) -> | |
5 | let did_init = ref false in | |
6 | if not !did_init then (Random.self_init (); did_init := true); | |
7 | match num_t with | |
8 | | Int -> (Array.init n (fun _ -> Random.int max_int) : t array) | |
9 | | Float -> (Array.init n (fun _ -> Random.float max_float) : t array) |