Skip to content

Instantly share code, notes, and snippets.

@freiksenet
Forked from kkirsanov/gist:1497547
Created December 19, 2011 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freiksenet/1497595 to your computer and use it in GitHub Desktop.
Save freiksenet/1497595 to your computer and use it in GitHub Desktop.
RLE
rle:: String -> [(String, Int)]
rle [] = error "Empty List"
rle [x] = [([x], 1)]
rle st@(x:xs) = (start, cnt) : rle ending where
start, ending = span (==x) st
cnt = length start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment