I need to count occurrences of element in list.
List looks like this: List[(String, String, Int)]
- list of (String, String, Int)
tuples.
Example:
List(("Gregor", "Math", 6), ("Mark", "Math", 33),
("Gregor", "IT", 44), ("Jane", "Math", 3),
("Mark", "Geography", 44), ("Gregor", "sdf", 32))
And I need to return list of pairs (name, occurrences in list) For this example it should be
List(("Gregor", 3), ("Mark", 2), ("Jane", 1))
I tried with map and foldLeft but i dont have idea how can I do that