Skip to content

Commit

Permalink
8 down, 91 to go.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdam committed Jun 11, 2014
1 parent 3339a9e commit 274bbaf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 8.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Eliminate consecutive duplicates of list elements.

myCompress :: (Eq a) => [a] -> [a]
myCompress [] = []
myCompress [x] = [x]
myCompress (x:xs)
| x == (head xs) = myCompress ([x] ++ tail xs)
| otherwise = [x] ++ myCompress xs

main = print (myCompress "AAAABBCDCEEEEA")

0 comments on commit 274bbaf

Please sign in to comment.