Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use OCaml's tuples to represent fractions as a pair of integers. For example, the value (1,2) of type int * intrepresents the value one-half; (5,8)
use OCaml's tuples to represent fractions as a pair of integers. For example, the value (1,2) of type int * intrepresents the value one-half; (5,8) represents the value five-eighths.
Write a fraction function that simplifies fractions. It should be called frac_simplify with type (int * int) -> (int * int).
Consider the following sample evaluations:
frac_simplify (8,16) evaluates to (1,2)
frac_simplify (4,9) evaluates to (4,9)
frac_simplify (3,9) evaluates to (1,3)
As before, you may assume that the denominator is never 0.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started