diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-03-17 11:05:29 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-03-17 11:05:29 +0800 |
commit | a9ee47b61558efe09aee23f5671aabd0c3747e8a (patch) | |
tree | 52426053545a54514d39300e2117bdda14a9b1ef /p10.hs | |
parent | 11a5fd38018498a7b7feb0e392ac36003b0440ac (diff) | |
download | h99-a9ee47b61558efe09aee23f5671aabd0c3747e8a.tar.gz h99-a9ee47b61558efe09aee23f5671aabd0c3747e8a.tar.bz2 h99-a9ee47b61558efe09aee23f5671aabd0c3747e8a.zip |
p -> h
Diffstat (limited to 'p10.hs')
-rw-r--r-- | p10.hs | 20 |
1 files changed, 0 insertions, 20 deletions
@@ -1,20 +0,0 @@ -import Control.Applicative -import Control.Arrow -import Data.List - -encode :: Eq a => [a] -> [(a,Int)] -encode = foldr elim [] - where - elim e [] = [(e,1)] - elim e p@(n:ns) - | e == fst n = (e,1 + (snd n)):ns - | otherwise = (e,1):p - -encode' (x:xs) = let (first,rest) = span (==x) xs - in (x,1+(length first)) : encode' rest - -encode' [] = [] - -encode'' xs = map (head &&& length) $ group xs - -encode''' xs = map ((,) <$> head <*> length) $ group xs |