Question
//in scala //please do not import or call anything and please follow the instructions or I will report the answer Write a function in Scala
//in scala
//please do not import or call anything and please follow the instructions or I will report the answer
Write a function in Scala whose parameters are: two lists of Ints, xs and ys, and a function f that takes in two Ints and returns an Int. The function should return a new list whose elements are obtained by applying f to the corresponding elements of xs and ys. Test your function using anonymous functions corresponding to f(x, y) = x+y and f(x, y) = x*x+y. For example, if xs was the list 3, 8, 1, 5 and ys was 12, 6, 23, 1, 8, 4 and the f used was f(x, y) = x+y, our result list would be 15, 14, 24, 6. Note that if one list is longer than the other, the extra elements are not included in the result list. You may NOT use a helper function with extra parameters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started