Create list subscriptions
I am new to haskell and tried to write a function to generate a strength set that only includes sequential subsets eg: [1,2,3] → [[], [1], [2], [3], [1,2], [2,3], [1,2,3]]
I found this on the blog http://davidtran.doublegifts.com/blog/?p=7
powerset :: [a] -> [[a]]
powerset [] = [[]]
powerset (x:xs) = powerset xs ++ map (x:) (powerset xs)
-- powerset (x:xs) = powerset xs ++ [x:xs' | xs' <- powerset xs]
but does this spawn all the subsets of ie [1,3] that I don't want? is there anyway to fix this code to work or i need to rethink my approach. Also I don't want to use the built-in library functions, I want my basic principles to be correct.
+3
source to share