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

  Create a subdirectory in your repository

CMPT 214: Programming Principles and Practice Assignment. Create a subdirectory in your repository for a new project called Lab09

  Write a do loop that reads integers and computes their sum

Write a do loop that reads integers and computes their sum. Stop when reading a zero or the same value twice in a row.

  Method takes string and integer as parameters

Write a method called multiConcat which takes a String and an integer as parameters. Return String made up of the string parameter concatenated with itself count times.

  Creating session by granting needed privilege

Make sure that Bob can't create objects greater than 512K in size in USERS01 tablespace. And now that user is created, ensure that Bob can create session, by granting needed privilege.

  Write a program to create an array called first

Write a program to create an array called first, initialized with your first name followed by a space, and then your last name in the ROM space. The main code should read each element of this array; convert it to uppercase and save it in an array ..

  Write a program to display sudoku board in video memory

Write a program to display sudoku board in video memory in Assembly language x86. Display a sudoku board using the ascii characters (179d- 218d1. use colors2.

  Write down pseudo code to find sentinel value

The total of both types have to be printed at end. Suppose 50 as sentinel value. Write down Pseudo Code to perform this function.

  Write pseudocode to show positive and negative numbers

Write down pseudocode which will accept 25 integers and show the number of positive and negative numbers. Mention whether pseudocode utilizes a finite or indefinite loop.

  Write a modular program to do initialize a two-d array

Write a modular program (minimum of NINE functions that have arguments or return values), to do the Initialize a two-dimensional array, representing the offices in the building, to all EMPTY offices.

  Define algorithm that inserts an integer x in given position

Describe an algorithm that inserts an integer x in the appropriate position into the list a1, a2,...,an of integers that are in increasing order.

  Calculate interest on account balance-get total amount due

Accepts account balance and calculates interest on Account balance. It then adds on interest to get total amount due.

  Write a bash shell script prompt user to enter first name

Write a Bash shell script named phone.bsh that prompts the user the to enter first or last or any portion of person's name, so that can be found the appropriate entry in the phone directory file.

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