
14 Sep
2015
14 Sep
'15
3:23 p.m.
On 2015-09-14 02:57 PM, JORGE MALDONADO wrote:
The powerset of set s is a set containing all subsets of s. I need a clue on how to write Haskell code to get the superset of a set using direct recursion and list comprehension.
"superset"? "subsets"? To compute all subsets of x:xs, i.e., "powerset (x:xs) = ?" : Suppose powerset xs correctly answers you all subsets of xs. How do you build upon its answer to obtain all subsets of x:xs? Basically, each subset of xs is also a subset of x:xs, so you want to include them in your answer for x:xs. On top of that, for each subset of xs, you can insert x and get a subset of x:xs, too. Does this cover all cases?