我有一个功能:
sigma(x: Int, y: Int, z: Int, a: Int)(f: (Int, Int, Int, Int) => Double): Double
我需要将其设置为另一个函数的参数:
bigPi(x: Int, y: Int, z: Int, a: Int)('Here should be sigma'):Double
如何正确定义sigma类型并将其用作bigPi的参数?
答案 0 :(得分:2)
def sigma(x:Int, y:Int, z:Int, a:Int)(f:(Int,Int,Int,Int) => Double):Double = 1.1
def bigPi(x: Int, y: Int, z: Int, a: Int)(
f: (Int,Int,Int,Int) => ((Int,Int,Int,Int) => Double) => Double
):Double = 2.2
bigPi(1,2,3,4)(sigma)
IntelliJ IDE表示没有多余的括号,但编译器则另有说明。
答案 1 :(得分:1)
尝试一下:
def bigPi(x: Int, y: Int, z: Int, a: Int)(s: (Int, Int, Int, Int) => ((Int, Int, Int, Int) => Double) => Double) = whatever