I have for example a map such as Map("a" -> 2, "b" -> 4). I want to convert it to a Sequence such that Seq("a", "a", "b", "b", "b", "b").
Im currently doing this:
(for (e <- theMap) yield
for (_ <- 0 until e._2) yield e._1).flatten).toSeq
My question is: what would be a better/more sophisticated approach to doing this because I am pretty sure the a double yield for loop is not necessary and scala allows you to it in a 'nicer' way.