Created
October 14, 2014 14:29
-
-
Save recursivecurry/ef7797fb4a5bb7494500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- subset generator | |
-- ./Test | |
-- 3 | |
-- [[1,2,3],[2,3],[1,3],[3],[1,2],[2],[1],[]] | |
-- ./Test | |
-- 4 | |
-- [[1,2,3,4],[2,3,4],[1,3,4],[3,4],[1,2,4],[2,4],[1,4],[4],[1,2,3],[2,3],[1,3],[3],[1,2],[2],[1],[]] | |
module Main where | |
subMain :: Int -> [Int] -> [[Int]] | |
subMain 0 elements = [elements] | |
subMain maxNum elements = (subMain (maxNum-1) (maxNum:elements)) ++ (subMain (maxNum-1) elements) | |
main :: IO () | |
main = | |
do line <- getLine | |
let maxNum = read line :: Int | |
let subSets = subMain maxNum [] | |
print subSets | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment