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 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
Heres an example implementation of the area function in Haskell data Shape Circle Float Rectangl... View full answer
Get step-by-step solutions from verified subject matter experts
