In the following exercises, implement sets as lists, where eachelement of a set appears exactly once in the list and the elementsappear in no particular order. Do not assume you can sort thelists. Do assume that input lists have no duplicate elements, anddo guarantee that output lists have no duplicate elements.

Exercise 11 Write a function to construct the powerset of any sat.A set's powerset is the set of all of its subsets. Considerthe set A = {1,2,3}. It has various subsets: {1}, {1,2} and so on.Of course the empty set is a subset of every set. The powerset of Ais the set of all subsets of A.

Your powerset function should take a list (representing the set)and return a list of lists (representing the set of all subsets ofthe original set.) powerset [1,2] should return [[1,2],[1],[2],[]](in any order). Your powerset function neet not work on the untypedempty list; it may ive an error message when evaluating powersetnil. But it should work on a typed empty list, so pwerset (nil :int list) should give the right answer ([[]]).

NOTE: although the textbook requires an answer in SML, I need ananswer in F#

Want an answer?

No answer yet. Submit this
question to the community.