Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming Logic & Design Comprehensive

Authors: Joyce Farrell

9th edition

978-1337102070

More Books

Students also viewed these Computer Engineering questions

Question

What research interests does the faculty member have?

Answered: 1 week ago