daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List (group)
  2.  
  3. data RunLength a = Single a | Multiple Int a deriving (Show, Eq)
  4.  
  5. encodeModified :: Eq a => [a] -> [RunLength a]
  6. encodeModified = map runLength . group
  7.     where runLength [x] = Single x
  8.           runLength xs@(x:_) = Multiple (length xs) x
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top