Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In HASKELL: 1. Datatype In 2C, analytic geometry, a circle could be denoted as, for instance. (43.1, 55.0,10.4) where the first and second fields are

In HASKELL:

1. Datatype

In 2C, analytic geometry, a circle could be denoted as, for instance. (43.1, 55.0,10.4) where the first and second fields are the coordinates of the circle, center and the third field is the radius. Similarly, a rectangle could be represented by (x1, y1, x2, y2) where (x1, y1) and (x2 ,y2) are the coordinates of two opposite corners of me rectangle. Let's say that a shape can be a circle or a rectangle: a. Make your own type to represent these shapes.

data Shape =

b. Lets make a function Nat takes a shape and returns its surface. Note that the area of a circle radius r is pi*^r^2 , and that of a rectangle is width*length

surface :: Shape -> Float

c. Assume that we make a data type that defines a point in 2D space: data Point = Point Float Float

Redefine your shape so Nat the center of a circle and the corners of a rectangle are now represented by data Point.

data Shape =

d. Adjust your surface function to reflect these changes.

surface :: Shape -> Float

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_2

Step: 3

blur-text-image_3

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions