Last active
August 29, 2015 14:09
-
-
Save shoooe/961a596b5d56a24235f3 to your computer and use it in GitHub Desktop.
Some exercise with Haskell
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
-- Original question can be found here: | |
-- http://www.reddit.com/r/haskell/comments/2lq8dt/produce_infinite_list_with_a_string/ | |
permWithRep :: Int -> [a] -> [[a]] | |
permWithRep = replicateM | |
allSets :: String -> [[String]] | |
allSets str = map (flip permWithRep $ str) [0..] | |
main :: IO () | |
main = do | |
print $ take 3 . allSets $ "ab" | |
-- [[""],["a","b"],["aa","ab","ba","bb"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment