Question: Define a function single : 'a list list -> 'a list which takes in input a list of lists and gives back the list consisting
Define a function single : 'a list list -> 'a list
which takes in input a list of lists and gives back the list consisting of all the elements, in the same order in which they appear in the argument.
Here is an SML mergesort program:

Suppose we delete the third line of mergesort, so that [a,b] is no longer handled as a base case. You can verify that this change makes no difference in the type of mergesort or in its behavior.
Now suppose we also delete the second line of mergesort, leaving

What effect does this change have on the type that SML infers for mergesort? Verify that whether updated mergesort works correctly by running on your system and explain your findings
fun merge (t), ys) ys I merge (xs, xs I merge (x: xs, y:: ys) if x y then x: merge (xs, ys) else y merge (x: :xs, ys) fun split split la ([a], I split (a :b: cs) let val M, N) split cs in (a M, b N) end fun mergesort mergesort la [aj I mergesort la,b if a b then a, b] else [b, aj I mergesort L let val (M, N) split L merge (mergesort M mergesort N) end Note that mergesort includes three base cases (CJ, Caj, a,b]) and all are handled correctly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
