f(x) = x+2
p(y) = if(y>2) true else false
List(4,7,1,3,9).collect{ case i
if p(f(i)) => f(i)}
This works – but if f(x) was a heavy compute function, it would mean I am forced to call it twice.
If I take output of f(x) into a val ,and feed into p(x) above – code wouldn’t compile.
How do I avoid the repeat call.