aboutsummaryrefslogtreecommitdiff
path: root/comparison/SML/bsort-40000.sml
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2021-10-24 23:04:45 +0900
committerShinya Sato <shinnya.sato@gmail.com>2021-10-24 23:04:45 +0900
commit787dc13c837f0955fbd85b8f26a05d720d361333 (patch)
treefec3abebb1e867e8b2239d7cf07b4c7d13ce0f81 /comparison/SML/bsort-40000.sml
parente607a57dfafb784c4e27da143214afb2ccd07fbf (diff)
downloadinpla-787dc13c837f0955fbd85b8f26a05d720d361333.tar.gz
inpla-787dc13c837f0955fbd85b8f26a05d720d361333.zip
Upload the comparison directory
Diffstat (limited to 'comparison/SML/bsort-40000.sml')
-rw-r--r--comparison/SML/bsort-40000.sml30
1 files changed, 30 insertions, 0 deletions
diff --git a/comparison/SML/bsort-40000.sml b/comparison/SML/bsort-40000.sml
new file mode 100644
index 0000000..48c3eb4
--- /dev/null
+++ b/comparison/SML/bsort-40000.sml
@@ -0,0 +1,30 @@
+(*
+https://gist.github.com/masquerade0324/68f4f3fd3ab897fbe1ad
+*)
+
+fun bs xs 0 = xs
+ | bs (x::y::ys) n =
+ if (x<y) then x::(bs (y::ys) (n-1))
+ else y::(bs (x::ys) (n-1))
+ | bs xs _ = xs;
+
+fun go xs 0 = xs
+ | go xs n = go (bs xs n) (n-1);
+
+
+fun bsort xs = go xs (length(xs) - 1);
+
+
+(* mkRandList *)
+local
+ val nextInt = Random.randRange(1,10000);
+ val r = Random.rand(1,1);
+in
+ fun mkRandList 0 = []
+ | mkRandList n = (nextInt r)::(mkRandList (n-1))
+end;
+
+
+bsort (mkRandList 40000);
+
+