Question: Code should be written in Haskell The following problems are to implement mathematical sets and their operations using Haskell lists. A set is an unordered

Code should be written in Haskell

Code should be written in Haskell The following problems are to implementmathematical sets and their operations using Haskell lists. A set is an

The following problems are to implement mathematical sets and their operations using Haskell lists. A set is an unordered collection of elements (objects) without duplicates, whereas a list is an ordered collection of elements in which multiplicity of the same element is allowed. Let us define Set as a type synonym for lists as follows: [Ref. Chapter 8, in particular, Section 8.1 Type declarations.] type Set a [a] Even though the two types - Set a and [a] - are the same to the Haskell compiler, they communicate to the programmer that values of the former are sets and those of the latter are Problem 11. (10 points) [Read Chapters 3, 4, and 6.] Set constructor. Write a recursive function that constructs a set. Constructing a set from a list simply means removing all duplicate values. Use isElement in the definition mkSet :: Eq a=> [a] -> Set a All the remaining functions can assume that their incoming set arguments are indeed sets (i.e, lists that do not contain duplicates), and correspondingly, your implementations must guarantee this property for the sets that are returned as results Problem 12. (5 points) Read Chapters 3-6.] Write a recursive function size that returns the number of elements in a set. Do not use the library function length size : Set a-Int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!