I have two PartialFunctions f
and g
.
They have no side effects and are quick to execute.
What\'s the best way to compose them into another partial func
val h = f.mapValues(g)
But that only works for maps. I don't think there is a short way of doing that for any kind of partial function, you'll just have to create a new PartialFunction object manually.
edit: I see my above code is not what you wanted. But maybe this is better
val h = f.collect { case (k, v) if(g.contains(v)) => (k, g(v)) }