Created
March 24, 2020 14:10
-
-
Save crclark96/6a8e90a3e997e5fa3a180f1324ebdb40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
l = ['a','a','b','b','b','c','c'] | |
compress :: [Char] -> [String] | |
compress l = group l >>= (\x -> [take 1 x, show $ length x]) | |
main = do | |
putStrLn . show $ compress l |
This file contains hidden or 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
/tmp | |
➜ runhaskell compress.hs | |
["a","2","b","3","c","2"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So clean!