Question: a.1 Write a function partial2 that takes as parameters a value a:A and a function f:(A,B,C)=>D, of 3 arguments, and returns as result a function

 a.1 Write a function partial2 that takes as parameters a value

a.1 Write a function partial2 that takes as parameters a value a:A and a function f:(A,B,C)=>D, of 3 arguments, and returns as result a function of two arguments that partially applies fto a. This is an extension of the textbook function partiall from 2 arguments to 3 arguments. a.2 Consider this function of three arguments: def formatstudentInfo(isGraduate: Boolean, year: Int, name: String) = { xal grad = if (is Graduate) "graduate" else "undergraduate" % student %s enrolled in year %dformat(grad, name, year) } Write code in function main that shows how to obtain a function of 2 parameters using partial2 that partially applies formatStudentinfe with parameter isGraduate set to true. Assign the new function to a val called format Graduate Std. Then write in main code that uses formatGraduate Std with some sample student information and display the resulting string. (Hint: if this sounds complicated, the problem wants to use partial2 in the same way the lecture notes show how to use partiall with a function of 2 arguments called firstN.Chars.) a.1 Write a function partial2 that takes as parameters a value a:A and a function f:(A,B,C)=>D, of 3 arguments, and returns as result a function of two arguments that partially applies fto a. This is an extension of the textbook function partiall from 2 arguments to 3 arguments. a.2 Consider this function of three arguments: def formatstudentInfo(isGraduate: Boolean, year: Int, name: String) = { xal grad = if (is Graduate) "graduate" else "undergraduate" % student %s enrolled in year %dformat(grad, name, year) } Write code in function main that shows how to obtain a function of 2 parameters using partial2 that partially applies formatStudentinfe with parameter isGraduate set to true. Assign the new function to a val called format Graduate Std. Then write in main code that uses formatGraduate Std with some sample student information and display the resulting string. (Hint: if this sounds complicated, the problem wants to use partial2 in the same way the lecture notes show how to use partiall with a function of 2 arguments called firstN.Chars.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!