Question: MAKE THIS SML CODE OUTPUT [1,2,3] fun merge([], ys) = ys | merge(xs, []) = xs | merge(x::xs, y::ys) = if x < y then

MAKE THIS SML CODE OUTPUT "[1,2,3]"

fun merge([], ys) = ys
| merge(xs, []) = xs
| merge(x::xs, y::ys) =
if x < y then x::merge(xs, y::ys)
else y::merge(x::xs, ys)

fun split [] = ([],[])
| split [a] = ([a],[])
| split (a::b::cs) =
let val (M,N) = split cs in
(a::M, b::N)
end

fun mergesort [] = []
| mergesort [a] = [a]
| mergesort [a,b] = if a <= b then [a,b] else [b,a]
| mergesort L =
let val (M,N) = split L
in
merge (mergesort M, mergesort N)
end

Step by Step Solution

3.68 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Given a function f a b cs and two lists xs a list and ys b list I can create a result z list b... View full answer

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 Computer Engineering Questions!