From a9abc1da41b56edbed00081800382e854d6698d0 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Tue, 31 Mar 2015 23:41:55 +0800 Subject: rename to H**, +31 +32 +33 +34 +35 +36 --- H11.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 H11.hs (limited to 'H11.hs') diff --git a/H11.hs b/H11.hs new file mode 100644 index 0000000..77b7295 --- /dev/null +++ b/H11.hs @@ -0,0 +1,15 @@ +import Control.Arrow +import Data.List + +data ListItem a = Single a | Multiple a Int + deriving (Show) + +encode :: Eq a => [a] -> [(a,Int)] +encode xs = map (head &&& length) $ group xs + +encodeModified :: Eq a => [a] -> [ListItem a] +encodeModified = map helper . encode + where + helper (a,1) = Single a + helper (a,c) = Multiple a c + -- cgit v1.2.3-70-g09d2