let cons_rat = function
str_n, str_d -> let
n = try (Big_int.big_int_of_string str_n)
with _ -> failwith ("cons_rat : " ^ str_n ^ " does not consist of an optional - or + sign followed by one or several decimal digits")
and
d = try (Big_int.big_int_of_string str_d)
with _ -> failwith ("cons_rat : " ^ str_d ^ " does not consist of an optional - or + sign followed by one or several decimal digits")
in
if Big_int.eq_big_int d Big_int.zero_big_int
then failwith ("cons_rat : " ^ str_d ^ " means zero")
else Rat (Num.div_num (Num.num_of_big_int n) (Num.num_of_big_int d))