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

Write a recursive method nmbdigits

Design and implement meanIter, the iterative version of the method - Write a recursive method nmbDigits which takes an integer value as parameter and returns the number of dig

Write a code to locate and rank keywords

You are working on the custom Web application to design document library for client. Write code to locate and rank the keywords. You have been given sample document to use for

Program to display contents of file in separate line

Display the contents of the file GRADES created in Problem 1. Each student's record should appear on a separate line and include the total score (the sum of the three tests)

Create the program uses two arrays to hold employee names

Create the program which uses two arrays: one to hold employee names and one to hold employee salaries (standard US currency, two decimal points). The program must prompt us

Write a method occuson that checks the appointment

Implement a superclass Appointment and subclasses Onrtime, Daily and Monthly. An appointment has a description ( for example " See the dentist") and a date. Write a method o

Procedure to draw shape of choice

Write a program with a suitable procedure to draw shape of your choice. Your program must then call the procedure 10 times to draw the shape.

Implement a program to solve the puzzle problem

In this project you will implement a program to solve the 8-puzzle problem using the A*, IDA* or RBFS algorithm. Your program should be a command line based program reading

Write a c api program under mysql to solve database query

In earlier assignment, we created a database with the following three relation schemes, where the data type for the attributes s and p is Varchar(10) under the SQL-standard, t

Reviews

Write a Review

 
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