fork download
  1. main = putStrLn $ rle "wwwwaaadexxxxxx"
  2.  
  3. split :: [Char] -> [[Char]]
  4. split str = reverse $ go [] (head str) str
  5. where go acc _ "" = acc
  6. go acc cur str = let newAcc = (takeWhile (==cur) str):acc
  7. newStr = dropWhile (==cur) str
  8. newCur = head newStr
  9. in
  10. go newAcc newCur newStr
  11.  
  12. rle :: [Char] -> [Char]
  13. rle "" = ""
  14. rle x = foldl (\acc x -> acc ++ (head x:(show $ length x))) "" . split $ x
  15.  
Success #stdin #stdout 0s 8388607KB
stdin
Standard input is empty
stdout
w4a3d1e1x6