Define functions numerator and denominator

Assignment Help Programming Languages
Reference no: EM132234287

The programming language is HASKELL.

Problem - 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.

Verified Expert

Haskell language is used for creating the machine perspective codes and in this code we have found the fraction simplification of the fraction as in haskell the numerator is not divisible by the denominator if they are not divisible so to simplify the fractions we have to use some library functions in haskell and that are used in this

Reference no: EM132234287

Questions Cloud

Terminate in the event of the employee disability : This provision indicates that the employment period shall terminate in the event of the employee’s disability.
Accountable for accurate business communication : Who is responsible and accountable for accurate business communication?
Pros-cons and usefulness of broaden and build theory : Pros, Cons, and usefulness of "Broaden and build" theory of positive enotions by Barbara L. Fredrickson?
Prepare a report for forecast income statements : Prepare a report for presentation to the board of directors - a justified recommendation as to the most appropriate source of finance
Define functions numerator and denominator : Define functions numerator and denominator to return the numerator and denominator, and functions whole and fractional to extract the whole and the fractional
Generate a heightmap and draw it as a Quad mesh : Choose a greyscale image, load it in Processing and use its pixel values to generate a heightmap and draw it as a Quad mesh
What type of work allow you to maintain professionalism : What type of work relationship will allow you to maintain professionalism with her without jeopardizing your job, and why? Choose one of the following.
Create an appropriate greeting and closing for each email : Create an appropriate greeting and closing for each email. Follow appropriate netiquette rules for electronic communication.
What would you say in the policy : You have been asked to draft a corporate usage policy regarding the use of instant messaging. The policy should encourage the use of IM and chat.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd