diff options
Diffstat (limited to 'comparison/SML')
| -rw-r--r-- | comparison/SML/bsort-40000.sml | 17 | ||||
| -rw-r--r-- | comparison/SML/isort-40000.sml | 21 | ||||
| -rw-r--r-- | comparison/SML/msort-800000.sml | 15 | ||||
| -rw-r--r-- | comparison/SML/qsort-800000.sml | 20 |
4 files changed, 64 insertions, 9 deletions
diff --git a/comparison/SML/bsort-40000.sml b/comparison/SML/bsort-40000.sml index e892f09..5e6e98b 100644 --- a/comparison/SML/bsort-40000.sml +++ b/comparison/SML/bsort-40000.sml @@ -15,7 +15,7 @@ fun go xs 0 = xs fun bsort xs = go xs (length(xs) - 1); -(* mkRandList *) +(* Creates a random list *) local val nextInt = Random.randRange(1,10000); val r = Random.rand(1,1); @@ -25,4 +25,17 @@ in end; -bsort (mkRandList 40000); +(* Validation checks *) +fun validation [] = true + | validation (x::xs) = + let fun validation_cons x [] = true + | validation_cons x (y::ys) = + if x<=y then validation_cons y ys + else false + in + validation_cons x xs + end; + + +(* Main *) +validation(bsort(mkRandList 40000)); diff --git a/comparison/SML/isort-40000.sml b/comparison/SML/isort-40000.sml index a851dbd..9fbaf09 100644 --- a/comparison/SML/isort-40000.sml +++ b/comparison/SML/isort-40000.sml @@ -8,7 +8,8 @@ fun insertsort [] = [] in insert(x, insertsort xs) end; -(* mkRandList *) + +(* Creates a random list *) local val nextInt = Random.randRange(1,10000); val r = Random.rand(1,1); @@ -16,5 +17,19 @@ in fun mkRandList 0 = [] | mkRandList n = (nextInt r)::(mkRandList (n-1)) end; - -insertsort (mkRandList 40000);
\ No newline at end of file + + +(* Validation checks *) +fun validation [] = true + | validation (x::xs) = + let fun validation_cons x [] = true + | validation_cons x (y::ys) = + if x<=y then validation_cons y ys + else false + in + validation_cons x xs + end; + + +(* Main *) +validation(insertsort(mkRandList 40000)); diff --git a/comparison/SML/msort-800000.sml b/comparison/SML/msort-800000.sml index 9209685..4ed65ea 100644 --- a/comparison/SML/msort-800000.sml +++ b/comparison/SML/msort-800000.sml @@ -28,7 +28,7 @@ fun msort [] = [] end; -(* mkRandList *) +(* Creates a random list *) local val nextInt = Random.randRange(1,10000); val r = Random.rand(1,1); @@ -38,5 +38,18 @@ in end; +(* Validation checks *) +fun validation [] = true + | validation (x::xs) = + let fun validation_cons x [] = true + | validation_cons x (y::ys) = + if x<=y then validation_cons y ys + else false + in + validation_cons x xs + end; + + +(* Main *) msort (mkRandList 800000); diff --git a/comparison/SML/qsort-800000.sml b/comparison/SML/qsort-800000.sml index e27af56..212029d 100644 --- a/comparison/SML/qsort-800000.sml +++ b/comparison/SML/qsort-800000.sml @@ -15,7 +15,7 @@ fun quicksort nil = nil end; -(* mkRandList *) +(* Creates a random list *) local val nextInt = Random.randRange(1,10000); val r = Random.rand(1,1); @@ -23,5 +23,19 @@ in fun mkRandList 0 = [] | mkRandList n = (nextInt r)::(mkRandList (n-1)) end; - -quicksort (mkRandList 800000); + + +(* Validation checks *) +fun validation [] = true + | validation (x::xs) = + let fun validation_cons x [] = true + | validation_cons x (y::ys) = + if x<=y then validation_cons y ys + else false + in + validation_cons x xs + end; + + +(* Main *) +validation(quicksort(mkRandList 800000)); |
