I want to have a function with signature :: [(Int,Char)] -> [String] which takes each Char and combines them into a list of Strings according to the Integer value in the corresponding pair...
ie.
[(0,'A'),(1,'B'),(2,'C'),(3,'D'),(0,'E'),(1,'F'),(2,'G'),(3,'H'),(0,'I'),(1,'J'),(2,'K'),(3,'L'),(0,'M'),(1,'N'),(2,'O'),(3,'P')]
Should generate the list: ["MIEA","NJFB","OKGC","PLHD"]
I've tried:
toList :: [(Int,Char)] -> Int -> [String]
toList [] a = []
toList (x:xs) a = [snd(x) | n <-[0..(a-1)], fst(x) == n]:toList xs a
but that just gives me:
["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"]
Any suggestions would be greatly appreciated.