Question: IN SCALA Problem 2E (7 points) : Convert a List of Strings into List of Tuples Write a function that achieves the following. Input: List

IN SCALAIN SCALA Problem 2E (7 points) : Convert a List of Strings

Problem 2E (7 points) : Convert a List of Strings into List of Tuples Write a function that achieves the following. Input: List of String Output: List of 4-tuples: wherein each tuple consists of the corresponding string in the input list, its length, its reverse and its index. See example below. Order of elements in the original list must be preserved. Example Input: List("Que", "Sera", "Sera", "Whatever", "Will", "Be") Output: List( ( "Que", 3, "euQ", 0), ("Sera", 4, "ares", 1), ("Sera", 4, "ares", 2), ("Whatever", 8, "revetahW", 3), ("Will", 4, "IIiW", 4), ("Be", 2, "eB", 5)) ) Restrictions You are allowed to use map, filter, foldLeft , foldRight , zip and zipWithIndex. All other list API functions are disallowed. String API functions: length and reverse are allowed. All other string API functions disallowed. Use of var, recursion or any kind of loop is forbidden. ]: i def convertListToListTuples (1st: List[String]): List[(String, Int, String, Int)] = { // YOUR CODE HERE 3 } 2

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!