For example: ʺaaaabbaabʺ->[(‘a’,4),(‘b’,2),(‘a’,2),(‘b’,1)] Its need to be done using FOLDR through one pass of the list, without using (++).
Here what I have so far
task2 (x:xs) = foldr (\c [(symbol, count)] -> if symbol == c then [(symbol, count+1)] else [(symbol, count)]) [(x, 1)] xs
The problem is I don't really understand how to make it go to the next element of the list after 'if' statement is False