Let's say I have a Scala collection of elements, and another collection of booleans, of the same size as the first collection (for the curious readers, the second collection is a result of Ramer-Douglas-Peucker algorithm).
Now I want to remove all the items from the first collection, where the second collection has false
at the same index, in a single pass, without creating intermediate collections. I couldn't find any of the built-in methods on any of the Scala collections that can do it. Of course I can write my own, but I'm surprised Scala collections doesn't one already. Am I just missing it?
Example:
List(1, 2, 3).removeWhere(List(false, true, false)) shouldEqual List(2)
// removeWhere is an imaginary name for the method I'm looking for