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 program to simulate deterministic finite automaton

Write a program to simulate any deterministic finite automaton. The set of states includes q0, q1, q2, ..., and the set of final states are in the input also.

  Creating personnel promotion application program

The following application program will be modified to accommodate the change to the database table. The personnel promotion application program.

  Create method to calculate value of product purchase

In addition, the receipt should display the value of the entire purchases. Create a method to calculate the value of the product purchases.

  Select a game that can be mapped by an automata

Select a game that can be mapped by an automata. This means the game will have a finite set of states (for whichcertain conditions are true) and an exit condition.

  Write a method named celsius that accepts a single argument

Write a method named Celsius that accepts a single argument, the temperature in Fahrenheit. The method should return the temperature converted to Celsius.

  Design a class named pet, which should have following fields

The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bird".

  Create the circle moving program using the new language

Create the circle moving program using the new language, and your reference sheet - Process Events needs to be called once each event loop to update SwinGame with the actions that have occurred since the last time through the loop.

  Write a checkbook application

I have attached a zip file of what I have completed so far in this checkbook organizer program. I need to edit this program so that the transactions entered into the checkbook application are able to be double clicked and view the details from a s..

  Implement a program that prompts the user for an integer

Implement a program that prompts the user for an integer n and prints the nth Fibonacci number, using the above algorithm.

  Write a program for a local charity

IT 102 Final Project - Golf-a-thon. Problem: You have been asked to write a program for a local charity that has an annual golf-a-thon to raise money

  Program for class quiz to implement measurable interface

State a class Quiz to implement Measurable interface. A quiz has a score and a letter grade (such as B+).

  Personal care limited pcl is a large and premier fmcg

personal care limited pcl is a large and premier fmcg company in india with a turnover of about rs 1200 crore. it has

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