Can anyone help me to generate all the subsets of a given set?
Example:If I have [2,3,4] and if I want K=2, that means I need pairs of two => [[2,3], [3,2], [2,4], [4,2], [3,4], [4,3]]
I wrote this code, but it generates only the number of subsets:
arrange::Int->Int->Int
arrange n 1=n
arrange n r=n*arrange (n-1) (r-1)
Another version, but this doesn't generate all solutions of the subsets:
arrange 0 _ =[[]]
arrange _ []=[]
arrange n (x:xs)=(map(x:)) (arrange (n-1) xs)++
(arrange n xs)