Unnamed
public text v1 · immutableimport Data.List
encode :: (Eq a) => [a] -> [(Int, a)]
encode s = [(length run, head run) | run <- group s]
decode :: [Char] -> [Char]
decode s | s == [] = ""
| otherwise = let (first, second) = span (\ch -> ch >= '0' && ch <= '9') s in
replicate (read first :: Int) (head second) ++ decode (tail second)
-- vim: ts=4 sw=4 et