Skip to content

Instantly share code, notes, and snippets.

@crclark96
Created March 24, 2020 14:10
Show Gist options
  • Save crclark96/6a8e90a3e997e5fa3a180f1324ebdb40 to your computer and use it in GitHub Desktop.
Save crclark96/6a8e90a3e997e5fa3a180f1324ebdb40 to your computer and use it in GitHub Desktop.

Revisions

  1. crclark96 created this gist Mar 24, 2020.
    7 changes: 7 additions & 0 deletions compress.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    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
    3 changes: 3 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    /tmp
    ➜ runhaskell compress.hs
    ["a","2","b","3","c","2"]