From 787dc13c837f0955fbd85b8f26a05d720d361333 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sun, 24 Oct 2021 23:04:45 +0900 Subject: Upload the comparison directory --- comparison/SML/msort-800000.sml | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 comparison/SML/msort-800000.sml (limited to 'comparison/SML/msort-800000.sml') diff --git a/comparison/SML/msort-800000.sml b/comparison/SML/msort-800000.sml new file mode 100644 index 0000000..2a33649 --- /dev/null +++ b/comparison/SML/msort-800000.sml @@ -0,0 +1,45 @@ +(* https://stackoverflow.com/questions/25839939/understanding-merge-sort-in-ml *) + +fun split [] = ([], []) + | split [a] = ([a], []) + | split (a::b::cs) = + let + val (m,n) = split cs + in + (a::m, b::n) + end; + +fun merge ([], ys) = ys + | merge (xs, []) = xs + | merge (x::xs, y::ys) = + if x