Skip to content

Instantly share code, notes, and snippets.

@benperez
Created March 8, 2016 19:33
Show Gist options
  • Select an option

  • Save benperez/678b4e6d7e2c9001ff6e to your computer and use it in GitHub Desktop.

Select an option

Save benperez/678b4e6d7e2c9001ff6e to your computer and use it in GitHub Desktop.

Revisions

  1. benperez created this gist Mar 8, 2016.
    8 changes: 8 additions & 0 deletions dropWhereRepeated.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    --dropWhereRepeated [1, 2, 2, 3, 3, 5, 7, 10]
    --[1,5,7,10]
    dropWhereRepeated :: (Eq a) => [a] -> [a]
    dropWhereRepeated [] = []
    dropWhereRepeated [x] = [x]
    dropWhereRepeated (x : y : xs)
    | x == y = dropWhereRepeated (dropWhile (== x) (xs))
    | otherwise = x : dropWhereRepeated (y : xs)