Haskell code question data MyRational = Frac Integer Integer -- Given integers n and d, create a new rational with n as

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Haskell code question data MyRational = Frac Integer Integer -- Given integers n and d, create a new rational with n as

Post by answerhappygod »

Haskell code question
data MyRational = Frac Integer Integer
-- Given integers n and d, create a new rational with n as thenumerator and d
-- as the denominator. Trying to create a rational withdenominator 0 is an
-- error. Call the error function to crash the function, e.g.error
-- "makeRational: denominator can't be 0"
makeRational :: Integer -> Integer -> MyRational
--code here
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply