Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using haskell Problem 3 [35 Points]. Declare a data type MyFraction for handling fractions - where each number is a (numerator, denominator) pair of integers

image text in transcribedUsing haskell

Problem 3 [35 Points]. Declare a data type MyFraction for handling fractions - where each number is a (numerator, denominator) pair of integers representing the numerator and the denominator of the fraction. For example, (22, 23) would represent 22 23. The numerator can be positive or negative, and the denominator must always be positive Carefully pick Haskell's built-in type classes which this type should be an instance of. You should define and when meaningful overload -simple arithmetic and comparison operations on these fractions (at least: *, /, +,-' neg negation), =.'--). Also define functions numerator and denominator to return the numerator and denominator, and functions whole and fractional to extract the whole and the fractional part of the fraction. For example, for (23, 22), whole should return 1, and fraction should return 1/22. Function fractional should return a MyFraction data type Problem 3 [35 Points]. Declare a data type MyFraction for handling fractions - where each number is a (numerator, denominator) pair of integers representing the numerator and the denominator of the fraction. For example, (22, 23) would represent 22 23. The numerator can be positive or negative, and the denominator must always be positive Carefully pick Haskell's built-in type classes which this type should be an instance of. You should define and when meaningful overload -simple arithmetic and comparison operations on these fractions (at least: *, /, +,-' neg negation), =.'--). Also define functions numerator and denominator to return the numerator and denominator, and functions whole and fractional to extract the whole and the fractional part of the fraction. For example, for (23, 22), whole should return 1, and fraction should return 1/22. Function fractional should return a MyFraction data type

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

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Describe how to recruit applicants.

Answered: 1 week ago

Question

Problem 1 -Raw Material

Answered: 1 week ago