In particular, for strings. Therefore, it will be required ["so", "what", "and", "so", "for" "so"]and returned ["so", "so", "so"]. My problem is that my function returns a list identical to the one that was entered.
Here are all the relevant codes:
lookAhead :: [String] -> String
lookAhead [] = []
lookAhead (c:cs) = c
groupFirst :: [String] -> [String]
groupFirst [] = []
groupFirst (x:xs)
| lookAhead xs == x = x : (groupFirst ((lookAhead xs):(tail xs)))
| lookAhead xs /= x = x : (groupFirst xs)
| lookAhead xs == [] = x : []
source
share