Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scala> List(4,5,5,5,10,13,13).foldLeft(Map.empty[Int, Int].withDefaultValue(0)){(acc, x) => acc + (x -> (acc(x) + 1))}
- res0: scala.collection.immutable.Map[Int,Int] = Map(4 -> 1, 5 -> 3, 10 -> 1, 13 -> 2)
Advertisement
Add Comment
Please, Sign In to add comment