Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Identify the types of informal reports.

Answered: 1 week ago

Question

Write messages that are used for the various stages of collection.

Answered: 1 week ago