Skip to content

Commit

Permalink
9 is not yet finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdam committed Jun 12, 2014
1 parent 274bbaf commit 4c0dc66
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 9.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Pack consecutive duplicates of list elements into sublists. If a list
-- contains repeated elements they should be placed in separate sublists.

myPack :: (Eq a) => [a] -> [a]
myPack [] = []
myPack [x] = [x]
myPack (x:xs)
| x == head xs = [x:myPack xs]
|

main = print (myPack ['a', 'a', 'a', 'a', 'b', 'c', 'c', 'a',
'a', 'd', 'e', 'e', 'e', 'e'])

0 comments on commit 4c0dc66

Please sign in to comment.