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
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Programming Logic & Design Comprehensive
Authors: Joyce Farrell
9th edition
978-1337102070
Students also viewed these Computer Engineering questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App