Is there a syntax for putting a type annotation on _ as in the following?
seq.fold(0)(_:Int + _:Int)
In particular, I’m trying to write the following.
def sumOfProducts[A](seq:Seq[Seq[A]], plus:(A,A)=>A, zero:A, times:(A,A)=>A, one:A):A = {
seq.foldLeft(zero) {
(sum, gamma) => plus(sum, gamma.fold(one)(times))
}
}
sumOfProducts(
Seq(Seq( 1, 2, 3), Seq(10, 20, 30), Seq(100, 200, 300)),
plus=(_:Int + _:Int),
zero=0,
times=(_:Int * _:Int),
one=1)