Created
May 22, 2012 03:03
-
-
Save dtchepak/2766263 to your computer and use it in GitHub Desktop.
Attempt at prob 11 from 99 Haskell probs
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
import Data.List (group) | |
data RunLength a = Single a | Multiple Int a deriving (Show, Eq) | |
encodeModified :: Eq a => [a] -> [RunLength a] | |
encodeModified = map runLength . group | |
where runLength [x] = Single x | |
runLength xs@(x:_) = Multiple (length xs) x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment