Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions