Problem 10 of the famous 99 Problems. I got 99 problems, but a Lisp ain’t one.
-
import Data.List
-
-
-
thing = "aaaabccaadeeee"
-
-
– My attempt got me close enough to consider it solved.
-
encode
:: (Eq a
) => [a
] -> [(Int, [a
])]
-
encode xs =
-
let groupList = groupBy (\x y -> x == y) xs
-
-
letterList
= map nub groupList
-
in zip lengths letterList
-
-
– from the haskell.org solutions:
-
encode2
:: (Eq a
) => [a
] -> [(Int, a
)]
-
This entry was posted in Haskell and tagged development, Encoding, haskell, haskell run, Problems, programming, run length encoding. Bookmark the
permalink. Trackbacks are closed, but you can .