Question: Given the Shape datatype definition below, write a function area = fn: Shape real that takes a Shape argument and computes the area appropriately,

Given the Shape datatype definition below, write a function area = fn: Shape  real that takes a Shape

Given the Shape datatype definition below, write a function area = fn: Shape real that takes a Shape argument and computes the area appropriately, as illustrated below. The area of a circle is r. Use Math.pi for . datatype Shape Circle of real I Rectangle of real real area should behave as follows: val c= Circle 3.0; val c Circle 3.0: Shape val r Rectangle (6.0, 7.0); = val r = Rectangle (6.0.7.0): Shape - area c; val it - area r; val it 42.0 real 28.2743338823 real

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an example implementation of the area function in Haskell data Shape Circle Float Rectangl... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!