Question: Problem 1 (5 Points) Given the following definitions data Shape = Circle Float | Rect Float Float area (Circle r) = pi * r^2 area
Problem 1 (5 Points) Given the following definitions data Shape = Circle Float | Rect Float Float area (Circle r) = pi * r^2 area (Rect x y) = x * y c1 = Circle 2.7 c2 = Circle 3.51 r1 = Rect 3 4.19 r2 = Rect 7.8 2.6 shapes = [c1,c2,r1,r2] 1. (1 point) What is the type of function area ? area ::
2. (1 point) What is the type of the following expression in GHCi ? > :t Rect 3.4 Rect 3.4 ::
3. (3 points) Define a function totalOfSomeArea using sum, filter, and map that, given a list of Shapes, first, calculate the area of each shape, and then, sum only the areas which are within the range of [20; 30]. Use a lambda expression for the predicate for filter. Give another definition using the function composition oper- ator (.). Show your work with intermediate steps.
Version 1. Without function composition. totalOfSomeArea ss = Version 2. With function composition. totalOfSomeArea ss =
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
