Let a fixed mapping
val m = (0 to 3).map {x => (x,x*10) }.toMap
m: scala.collection.immutable.Map[Int,Int] = Map(0 -> 0, 1 -> 10, 2 -> 20, 3 -> 30)
set of keys of interest
val k = Set(0,2)
and functions
def f(i:Int) = i + 1
How to apply fto values in a map displayed by keys of interest so that the resulting map is
Map(0 -> 1, 1 -> 10, 2 -> 21, 3 -> 30)
source
share