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/isort-40000.sml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 comparison/SML/isort-40000.sml (limited to 'comparison/SML/isort-40000.sml') diff --git a/comparison/SML/isort-40000.sml b/comparison/SML/isort-40000.sml new file mode 100644 index 0000000..973d6e6 --- /dev/null +++ b/comparison/SML/isort-40000.sml @@ -0,0 +1,21 @@ +(* http://www.codecodex.com/wiki/Insertion_sort#Standard_ML *) +fun insertsort [] = [] + | insertsort (x::xs) = + let fun insert (x, []) = [x] + | insert (x, y::ys) = + if x<=y then x::y::ys + else y::insert(x, ys) + in insert(x, insertsort xs) + end; + + +(* 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; + +insertsort (mkRandList 40000); \ No newline at end of file -- cgit v1.2.3