我想提出一個簡單的函數,以整數的功能,列表和應用功能上的每個整數列表 -斯卡拉`應用程序並不需要parameters`編譯錯誤
def IntOps(f: Int => Int)(values: List[Int]): Int = {
if(values.isEmpty) 0
//Getting "Application does not take parameters" in values.tail
else IntOps(f(values.head)(values.tail))
}
IntOps(x=> x+x)(List(1, 2, 30)
我我在values.tail
上得到了一個編譯器錯誤Application does not take parameters
,我對函數式編程和scala都是初學者,所以任何能夠理解這一點的指針或答案都會很棒。
我得到「'Int'不帶參數」 – pedrofurla
IntOps應該做什麼?我看不到如何使用函數Int => Int將List [Int]轉換爲Int。 – pedrofurla