View difference between Paste ID: 6UG6xx2f and sDeshprJ
SHOW: | | - or go back to the newest paste.
1-
type nums = [`Int | `Float]
1+
type 'a nums = Int : int nums | Float : float nums
2
3
let random_array =
4
  let did_init = ref false in
5-
  fun n (num_t : nums) ->
5+
6
  fun (type t) n (num_t : t nums) ->
7-
  | `Int -> Array.init n (fun _ -> Random.int max_int)
7+
8-
  | `Float -> Array.init n (fun _ -> Random.float max_float)
8+
  | Int -> (Array.init n (fun _ -> Random.int max_int) : t array)
9
  | Float -> (Array.init n (fun _ -> Random.float max_float) : t array)