Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago