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 program to decodes messages using caesar cypher

Write a program which decodes messages. Messages will be encoded using Caesar cypher, with each letter being decoded by replacing it with the previous letter in the alphabet.

  The heap consists of exactly the nine cars on three trains

Suppose the heap consists of exactly the nine cars on three trains shown in given figure.- Object o in car 11 has references from cars 12, 23, and 32. When we garbage collect car 11, where might o wind up.

  Writie a program that computes the salaries of employees

The first programming project involves writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes.

  Determine the first two lines of the new file

Determine the first two lines of the new file created by the code below. This exercise refers to the file Justices.txt that contains data about the Supreme Court justices, past and present.

  Smallest and largest values in element floating-point array

Copy 11-elemts array source into first portion of 34-element array sourceCopy. Find out the smallest and largest values in 99-Element floating-point array data.

  Discuss the features of object oriented programming language

Discuss the features of object oriented programming languages. A perfect square is a number that can be expressed as the product of two equal integers. Draw a flowchart, and write a corresponding class oriented program to check if any entered numbe..

  Write a class called card that contains instance data

Write a class called Card that contains instance data to represent playing card with face and a suit. Create a class called DeckofCards that stores 52 objects.

  Explain programming language is machine independent

Explain what does it mean to say that programming language is machine independent? What do you mean by operator precedence? Depending on operator precedence, what values could be related with expression 6 + 2 * 3?

  Create an abstract representation of a generic animal

Create an abstract representation of a generic Animal that has the at least two polymorphic methods for making a sound and showing the image of the animal.

  What is the height of the retinal image

Create a binary image at least 64x64 in dimensions. Using Octave's existing functions, perform Average, Gaussian and Laplacian filters on the image. Display the original image and each of the filtered images in Octave plots. Discuss and compare your..

  Create an employee object using the default constructor

Create an Employee object using the default constructor. Format the currency using the following formatting services. Display the Employee information.

  Calculate the result of three variables

Interactive Programming ICT2612 - In an Android project the folder includes the resource files for the project - calculate the Result of three variables

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