1

I have a function:

sigma(x: Int, y: Int, z: Int, a: Int)(f: (Int, Int, Int, Int) => Double): Double

I need to set it as a parameter of another function:

bigPi(x: Int, y: Int, z: Int, a: Int)('Here should be sigma'):Double

How to define a type of sigma correctly and use it as an argument of bigPi?

1
  • Note: those two are not functions. They are methods. Functions and methods are fundamentally different. Commented Nov 7, 2018 at 16:57

2 Answers 2

3
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)

The IntelliJ IDE says there are unnecessary parentheses but the compiler says otherwise.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

def bigPi(x: Int, y: Int, z: Int, a: Int)(s: (Int, Int, Int, Int) => ((Int, Int, Int, Int) => Double) => Double) = whatever

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.