Question: Consider a function transformList that applies a function parameter fun to all elements of list Ist and returns a new list with the results: def

 Consider a function transformList that applies a function parameter fun to

Consider a function transformList that applies a function parameter fun to all elements of list Ist and returns a new list with the results: def transformList[T1, T2](Ist: List[T1], fun: T1 => T2): List[T2] = { if (Ist == Nil) Nil else fun(Ist.head) :: transformList(Ist.tail, fun) } // example how to use it: val numbers - List(3,4,5,1) val square Strings = transformList(numbers, (x: Int) => (x * x).toString) Which of the following statements are true ? transformList is tail recursive transformList is a higher order function stack overflow may happen if the actual argument list is too long T1 and T2 are type variables transformList is a polymorphic function

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!