daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. open Big_int;;
  2.  
  3.  
  4. let f (ratio_create: Big_int.big_int -> Big_int.big_int -> Ratio.ratio) k =
  5.   let rec aux_f numerator denominator =
  6.     if eq_big_int denominator unit_big_int then numerator
  7.     else
  8.       begin
  9.         let r = ratio_create numerator denominator in
  10.         Format.printf "%s@." (Ratio.string_of_ratio r);
  11.         if not (Ratio.is_normalized_ratio r)
  12.         then Format.printf "Unnormalized@.";
  13.           aux_f
  14.           (succ_big_int (Ratio.numerator_ratio r))
  15.           (pred_big_int (Ratio.denominator_ratio r))
  16.       end
  17.   in aux_f unit_big_int k
  18. ;;
  19.  
  20. Format.printf "%s@.@."
  21.   (string_of_big_int (f Ratio.create_ratio (big_int_of_int 20)));;
  22. Format.printf "%s@."
  23.   (string_of_big_int (f Ratio.create_normalized_ratio (big_int_of_int 20)));;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top