Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this problem introduces a hash function that operates on letters instead of bina

ID: 3721871 • Letter: T

Question

this problem introduces a hash function that operates on letters instead of binary data this problem introduces a hash function that operates on letters instead of binary data this problem introduces a hash function that operates on letters instead of binary data Currying is a transformation which converts a function f of two arguments into a function of one argument that partially applies f. Consider the following function f written in Scala: def f (a: Int) (b: Int) (c: Double) (d: Double) : Double = a * c + b * d What are the three types that make the following statements compile. def g: -() (2) (3.0) def h: = f (i) (-) def k: = f (1)

Explanation / Answer

With currying function 'f' , type of function f is:

Int => (Int => (Double =>(Double => Double)))= <Function>

The other definitions g,h and k are based on the above function f.

g has the type:

Double => Double

as only one argument of type double is missing in the partially applied function f that is assigned in rhs of the function definition g.This missing argument will become the argument of this new function to apply on the partially applied function.

h has the type:

(Double,Double) => Double

as only two arguments of type double is missing in the partially applied function f that is assigned in rhs of the function definition h.These missing arguments will become the arguments of this new function to apply on the partially applied function.

k has the type:

(Int, Double,Double) => Double

as one Int argument and two arguments of type double are missing in the partially applied function f that is assigned in rhs of the function definition h. These missing arguments will become the arguments of this new function to apply on the partially applied function.