Question: I have written a flatten function from scratch that takes a nested list as input and outputs another. def flatten[A] (list:List[List[A]]):List[A] I used scala's ':::'

I have written a flatten function from scratch that takes a nested list as input and outputs another.

def flatten[A] (list:List[List[A]]):List[A]

I used scala's ':::' to bind the two lists and it worked fine. However, my exercise prohibits me from using that or any built in method ( exercise from a personal scala book).

Now, i have written a helper method that merges those two list called merge.

How would merge fit in a new version of flatten?

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!