Skip to content

Instantly share code, notes, and snippets.

@beastaugh
Created September 1, 2011 10:26
Show Gist options
  • Save beastaugh/1185896 to your computer and use it in GitHub Desktop.
Save beastaugh/1185896 to your computer and use it in GitHub Desktop.
Drop consecutive elements of a list if they're the same, e.g. "AAABBACDDD" => "ABACD"
module Data.List.DropConsec
( dropConsec
) where
import Data.List (dropWhile)
dropConsec :: Eq a => [a] -> [a]
dropConsec [] = []
dropConsec (x:xs) = x : dropConsec (dropWhile (== x) xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment