Question: C: All List Elements That are Greater Than Their Index (6 points) Write a list function that inputs a list of integers lst and outputs

 C: All List Elements That are Greater Than Their Index (6

C: All List Elements That are Greater Than Their Index (6 points) Write a list function that inputs a list of integers lst and outputs a list consisting of all those elements in Ist whose values are strictly greater than their indices. Indices of elements start at 0 and go upto length of list -1. The order of the elements in the original list must be preserved in the returned list. Restrictions You may use these list API functions: zip, zipWithIndex (read documentation), map, foldLeft , foldRight and filter. No other list API functions are allowed. Use of loops, var, recursion not allowed. Example Input: List(1, 2, 2, -2, 4, 6,8) Output: List(1, 2, 6, 8) Note that elements 1 (index 0), 2 (index 1), 6 (index 5) and 8 (index 6) are returned. : = { 1 def listElementsGreaterThanIndex(1st: List[Int]): List[Int] 2 // YOUR CODE HERE 3 ??? 4 }

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!