I am learning currying in scala and trying to apply my knowledge on the following piece of code.
object excercise { def sqrt2(input : Double) : ((Double, Double) => Double, Double) => Double = { def iter(guessFxn : (Double, Double) => Double, initial : Double) : Double = { if (isGoodEnough(initial)) initial else { val newGuess: Double = guessFxn(initial, input) iter(guessFxn, newGuess) } } iter def isGoodEnough(guess: Double): Boolean = { math.abs(guess * guess - input ) / input < 0.001 } } println(sqrt2(2) ( (g: Double, c: Double) => (g + c / g) / 2, 1)) } What i want to achieve is that sqrt2 should return a function which takes as 2 arguments
1. fxn(that takes 2 doubles as arg and return a double val)
2. double val
When i am trying to run the worksheet it is giving me error
Error: missing arguments for method iter; follow this method with `_' if you want to treat it as a partially applied function iter ^ Error: type mismatch; found : Unit required: ((Double, Double) => Double, Double) => Double } ^ Error: missing arguments for method iter; follow this method with `_' if you want to treat it as a partially applied function iter ^