Question: I am trying to write a SML recursive function called mergePass that will take a list of list and merge pairs of the list. The
I am trying to write a SML recursive function called mergePass that will take a list of list and merge pairs of the list. The number of sublist does not have to be even for example: mergePass([[24],[39],[50],[28],[50],[1],[15],[1],[35],[40],[9],[8],[25],[1],[2]]) returns [[24,39],[28,50],[1,50],[1,15],[35,40],[8,9],[1,25],[2]]
mergePass([[24,39],[28,50],[1,50],[1,15],[35,40],[8,9],[1,25],[2]]) returns [[24,28,39,50],[1,1,15,50],[8,9,35,40],[1,2,25]]
I have this section of code I was trying out hd(x)@hd(tl(x)). If I was to enter [[1],[9],[7],[12]] or any other list of list in place of x it would give me back [1,9] but I need to recursively be able to go through the rest of the list and make other pairs This may not be the only or easiest way to do it but it is all I can come up with
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
