Skip to content

Instantly share code, notes, and snippets.

@gazliddon
Created July 10, 2015 18:03
Show Gist options
  • Save gazliddon/4dbd688c684e09f18ef1 to your computer and use it in GitHub Desktop.
Save gazliddon/4dbd688c684e09f18ef1 to your computer and use it in GitHub Desktop.
RLE in Haskell
--------------------------------------------------------------------------------
-- Run length encode
encode :: Eq a => [a] -> [(Int, a)]
encode xs = map (\x -> (length x , head x)) (group xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment