aboutsummaryrefslogtreecommitdiff
path: root/comparison
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:47:28 +0900
committerShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:47:28 +0900
commit7ea48cd96551247ecc763a5e42404ffa3464d0b0 (patch)
treefd1b63ab48d98a9243d3053522e17e31b9dc033f /comparison
parent950e2cb2184cb7ead93ba8df691a190598ed242f (diff)
parent429543c748aaf81b2a4207318eb5a05259469b21 (diff)
downloadinpla-7ea48cd96551247ecc763a5e42404ffa3464d0b0.tar.gz
inpla-7ea48cd96551247ecc763a5e42404ffa3464d0b0.zip
Merge branch 'develop'
Diffstat (limited to 'comparison')
-rw-r--r--comparison/Haskell/bsort-40000.hs10
-rw-r--r--comparison/Haskell/isort-40000.hs10
-rw-r--r--comparison/Haskell/msort-800000.hs12
-rw-r--r--comparison/Haskell/qsort-800000.hs12
-rw-r--r--comparison/Inpla/src/bsort-40000-reuse.in35
-rw-r--r--comparison/Inpla/src/bsort-40000.in35
-rw-r--r--comparison/Inpla/src/isort-40000-reuse.in34
-rw-r--r--comparison/Inpla/src/isort-40000.in34
-rw-r--r--comparison/Inpla/src/msort-800000-reuse.in59
-rw-r--r--comparison/Inpla/src/msort-800000.in59
-rw-r--r--comparison/Inpla/src/qsort-800000-reuse.in46
-rw-r--r--comparison/Inpla/src/qsort-800000.in46
-rw-r--r--comparison/OCaml/bsort40000.ml14
-rw-r--r--comparison/OCaml/isort40000.ml22
-rw-r--r--comparison/OCaml/msort800000.ml16
-rw-r--r--comparison/OCaml/qsort800000.ml18
-rw-r--r--comparison/Python/bsort-40000.py13
-rw-r--r--comparison/Python/isort-40000.py11
-rw-r--r--comparison/Python/msort-800000.py11
-rw-r--r--comparison/Python/qsort-800000.py12
-rw-r--r--comparison/SML/bsort-40000.sml17
-rw-r--r--comparison/SML/isort-40000.sml21
-rw-r--r--comparison/SML/msort-800000.sml15
-rw-r--r--comparison/SML/qsort-800000.sml20
24 files changed, 439 insertions, 143 deletions
diff --git a/comparison/Haskell/bsort-40000.hs b/comparison/Haskell/bsort-40000.hs
index 401ceaf..90f208c 100644
--- a/comparison/Haskell/bsort-40000.hs
+++ b/comparison/Haskell/bsort-40000.hs
@@ -30,7 +30,15 @@ randomList n = do
return (r:rs)
+validation [] = True
+validation (x:xs) = validation_cons x xs
+validation_cons x [] = True
+validation_cons x (y:ys) =
+ if x<=y then validation_cons y ys
+ else False
+
+
main = do
list <- randomList 40000
let sorted = bsort list
- print (take 10 sorted)
+ print (validation sorted)
diff --git a/comparison/Haskell/isort-40000.hs b/comparison/Haskell/isort-40000.hs
index 1abc148..68200af 100644
--- a/comparison/Haskell/isort-40000.hs
+++ b/comparison/Haskell/isort-40000.hs
@@ -25,7 +25,15 @@ randomList n = do
return (r:rs)
+validation [] = True
+validation (x:xs) = validation_cons x xs
+validation_cons x [] = True
+validation_cons x (y:ys) =
+ if x<=y then validation_cons y ys
+ else False
+
+
main = do
list <- randomList 40000
let sorted = isort list
- print (take 10 sorted)
+ print (validation sorted)
diff --git a/comparison/Haskell/msort-800000.hs b/comparison/Haskell/msort-800000.hs
index eb1a24d..65a5807 100644
--- a/comparison/Haskell/msort-800000.hs
+++ b/comparison/Haskell/msort-800000.hs
@@ -28,6 +28,7 @@ msort xs = merge (msort m, msort n)
main = print $ msort [3,2,8,5]
-}
+
randomList :: Int -> IO([Int])
randomList 0 = return []
randomList n = do
@@ -36,10 +37,15 @@ randomList n = do
return (r:rs)
+validation [] = True
+validation (x:xs) = validation_cons x xs
+validation_cons x [] = True
+validation_cons x (y:ys) =
+ if x<=y then validation_cons y ys
+ else False
+
main = do
list <- randomList 800000
let sorted = msort list
- print (take 10 sorted)
-
-
+ print (validation sorted)
diff --git a/comparison/Haskell/qsort-800000.hs b/comparison/Haskell/qsort-800000.hs
index 2a9d60d..72f7a03 100644
--- a/comparison/Haskell/qsort-800000.hs
+++ b/comparison/Haskell/qsort-800000.hs
@@ -15,10 +15,12 @@ part pivot (x:xs)
where
(below, above) = part pivot xs
+
{-
main = print $ qsort [3,2,8,5]
-}
+
randomList :: Int -> IO([Int])
randomList 0 = return []
randomList n = do
@@ -27,7 +29,15 @@ randomList n = do
return (r:rs)
+validation [] = True
+validation (x:xs) = validation_cons x xs
+validation_cons x [] = True
+validation_cons x (y:ys) =
+ if x<=y then validation_cons y ys
+ else False
+
+
main = do
list <- randomList 800000
let sorted = qsort list
- print (take 10 sorted)
+ print (validation sorted)
diff --git a/comparison/Inpla/src/bsort-40000-reuse.in b/comparison/Inpla/src/bsort-40000-reuse.in
index 3abd0ec..5908f83 100644
--- a/comparison/Inpla/src/bsort-40000-reuse.in
+++ b/comparison/Inpla/src/bsort-40000-reuse.in
@@ -1,7 +1,7 @@
// Bubble sort
-BS(ret) >< [] => ret~[];
-BS(ret) >< x:xs => (*L)BS(ret)~cnt, (*R)B(cnt, x)~xs;
-BS(ret) >< M(x) => ret~x;
+bsort(ret) >< [] => ret~[];
+bsort(ret) >< x:xs => (*L)bsort(ret)~cnt, (*R)B(cnt, x)~xs;
+bsort(ret) >< M(x) => ret~x;
B(ret, int x) >< [] => ret~M([x]);
B(ret, int x) >< M(w) => ret~M(x:w);
@@ -10,14 +10,31 @@ B(ret, int x) >< (int y):ys
| _ => ret~(*R)(y:cnt), (*L)B(cnt, x)~ys;
+// Creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=40000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+bsort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-BS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/bsort-40000.in b/comparison/Inpla/src/bsort-40000.in
index d0a5e1c..d3c8267 100644
--- a/comparison/Inpla/src/bsort-40000.in
+++ b/comparison/Inpla/src/bsort-40000.in
@@ -1,7 +1,7 @@
// Bubble sort
-BS(ret) >< [] => ret~[];
-BS(ret) >< x:xs => BS(ret)~cnt, B(cnt, x)~xs;
-BS(ret) >< M(x) => ret~x;
+bsort(ret) >< [] => ret~[];
+bsort(ret) >< x:xs => bsort(ret)~cnt, B(cnt, x)~xs;
+bsort(ret) >< M(x) => ret~x;
B(ret, int x) >< [] => ret~M([x]);
B(ret, int x) >< M(w) => ret~M(x:w);
@@ -10,14 +10,31 @@ B(ret, int x) >< (int y):ys
| _ => ret~(y:cnt), B(cnt, x)~ys;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=40000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+bsort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-BS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/isort-40000-reuse.in b/comparison/Inpla/src/isort-40000-reuse.in
index 3e7e2d2..1f7153d 100644
--- a/comparison/Inpla/src/isort-40000-reuse.in
+++ b/comparison/Inpla/src/isort-40000-reuse.in
@@ -1,6 +1,6 @@
// Insertion sort
-IS(ret) >< [] => ret~[];
-IS(ret) >< x:xs => (*L)I(ret, x)~cnt, (*R)IS(cnt)~xs;
+isort(ret) >< [] => ret~[];
+isort(ret) >< x:xs => (*L)I(ret, x)~cnt, (*R)isort(cnt)~xs;
I(ret, int x) >< [] => ret~[x];
I(ret, int x) >< (int y):ys
@@ -8,13 +8,31 @@ I(ret, int x) >< (int y):ys
| _ => ret~(*L)(y:cnt), (*R)I(cnt, x)~ys;
-const LIST_ELEM=40000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-IS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=40000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+isort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/isort-40000.in b/comparison/Inpla/src/isort-40000.in
index 295f6f4..0e3ed32 100644
--- a/comparison/Inpla/src/isort-40000.in
+++ b/comparison/Inpla/src/isort-40000.in
@@ -1,6 +1,6 @@
// Insertion sort
-IS(ret) >< [] => ret~[];
-IS(ret) >< x:xs => I(ret, x)~cnt, IS(cnt)~xs;
+isort(ret) >< [] => ret~[];
+isort(ret) >< x:xs => I(ret, x)~cnt, isort(cnt)~xs;
I(ret, int x) >< [] => ret~[x];
I(ret, int x) >< (int y):ys
@@ -8,13 +8,31 @@ I(ret, int x) >< (int y):ys
| _ => ret~(y:cnt), I(cnt, x)~ys;
-const LIST_ELEM=40000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-IS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=40000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+isort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/msort-800000-reuse.in b/comparison/Inpla/src/msort-800000-reuse.in
index 5f57484..4572623 100644
--- a/comparison/Inpla/src/msort-800000-reuse.in
+++ b/comparison/Inpla/src/msort-800000-reuse.in
@@ -1,34 +1,51 @@
// Merge sort
-MS(ret) >< [] => ret~[];
-MS(ret) >< x:xs => (*L)MS_tail(ret, x)~xs;
+msort(ret) >< [] => ret~[];
+msort(ret) >< x:xs => (*L)msort_tail(ret, x)~xs;
-MS_tail(ret, int n) >< [] => ret~[n];
-MS_tail(ret, int n) >< x:xs =>
- Split(left,right) ~ (*R)(n:x:xs),
- MS(a)~left, MS(b)~right, (*L)Merge(ret,b)~a;
+msort_tail(ret, int n) >< [] => ret~[n];
+msort_tail(ret, int n) >< x:xs =>
+ split(left,right) ~ (*R)(n:x:xs),
+ msort(a)~left, msort(b)~right, (*L)merge(ret,b)~a;
-Merge(ret, snd) >< [] => ret~snd;
-Merge(ret, snd) >< x:xs => (*L)MergeCC(ret, x, xs)~snd;
+merge(ret, snd) >< [] => ret~snd;
+merge(ret, snd) >< x:xs => (*L)mergeCC(ret, x, xs)~snd;
-MergeCC(ret, int y, ys) >< [] => ret~(*R)(y:ys);
-MergeCC(ret, int y, ys) >< (int x):xs
-| x <= y => ret~(x:cnt), (*L)MergeCC(cnt, y, ys) ~ xs
-| _ => ret~(y:cnt), (*L)MergeCC(cnt, x, xs) ~ ys;
+mergeCC(ret, int y, ys) >< [] => ret~(*R)(y:ys);
+mergeCC(ret, int y, ys) >< (int x):xs
+| x <= y => ret~(x:cnt), (*L)mergeCC(cnt, y, ys) ~ xs
+| _ => ret~(y:cnt), (*L)mergeCC(cnt, x, xs) ~ ys;
-Split(right,left) >< [] => right~[], left~[];
-Split(right,left) >< x:xs =>
- right~(*R)(x:cntl), left~cntr, (*L)Split(cntr,cntl)~xs;
+split(right,left) >< [] => right~[], left~[];
+split(right,left) >< x:xs =>
+ right~(*R)(x:cntl), left~cntr, (*L)split(cntr,cntl)~xs;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=800000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+msort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-MS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/msort-800000.in b/comparison/Inpla/src/msort-800000.in
index b77f353..3c43aa6 100644
--- a/comparison/Inpla/src/msort-800000.in
+++ b/comparison/Inpla/src/msort-800000.in
@@ -1,34 +1,51 @@
// Merge sort
-MS(ret) >< [] => ret~[];
-MS(ret) >< x:xs => MS_tail(ret, x)~xs;
+msort(ret) >< [] => ret~[];
+msort(ret) >< x:xs => msort_tail(ret, x)~xs;
-MS_tail(ret, int n) >< [] => ret~[n];
-MS_tail(ret, int n) >< x:xs =>
- Split(left,right) ~ (n:x:xs),
- MS(a)~left, MS(b)~right, Merge(ret,b)~a;
+msort_tail(ret, int n) >< [] => ret~[n];
+msort_tail(ret, int n) >< x:xs =>
+ split(left,right) ~ (n:x:xs),
+ msort(a)~left, msort(b)~right, merge(ret,b)~a;
-Merge(ret, snd) >< [] => ret~snd;
-Merge(ret, snd) >< x:xs => MergeCC(ret, x, xs)~snd;
+merge(ret, snd) >< [] => ret~snd;
+merge(ret, snd) >< x:xs => mergeCC(ret, x, xs)~snd;
-MergeCC(ret, int y, ys) >< [] => ret~(y:ys);
-MergeCC(ret, int y, ys) >< (int x):xs
-| x <= y => ret~(x:cnt), MergeCC(cnt, y, ys) ~ xs
-| _ => ret~(y:cnt), MergeCC(cnt, x, xs) ~ ys;
+mergeCC(ret, int y, ys) >< [] => ret~(y:ys);
+mergeCC(ret, int y, ys) >< (int x):xs
+| x <= y => ret~(x:cnt), mergeCC(cnt, y, ys) ~ xs
+| _ => ret~(y:cnt), mergeCC(cnt, x, xs) ~ ys;
-Split(right,left) >< [] => right~[], left~[];
-Split(right,left) >< x:xs =>
- right~(x:cntl), left~cntr, Split(cntr,cntl)~xs;
+split(right,left) >< [] => right~[], left~[];
+split(right,left) >< x:xs =>
+ right~(x:cntl), left~cntr, split(cntr,cntl)~xs;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=800000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+msort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-MS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/qsort-800000-reuse.in b/comparison/Inpla/src/qsort-800000-reuse.in
index 810e446..7f41045 100644
--- a/comparison/Inpla/src/qsort-800000-reuse.in
+++ b/comparison/Inpla/src/qsort-800000-reuse.in
@@ -1,26 +1,44 @@
// Quick sort
-QS(ret) >< [] => ret~(*R)[];
-QS(ret) >< (int x):xs =>
- (*R)Part(x, left, right)~xs,
- (*L)QS(cntl)~left, QS(cntr)~right,
+qsort(ret) >< [] => ret~(*R)[];
+qsort(ret) >< (int x):xs =>
+ (*R)part(x, left, right)~xs,
+ (*L)qsort(cntl)~left, qsort(cntr)~right,
Append(ret, x:cntl)~cntr;
// Note: `Append' is implemented as built-in.
-Part(int x, a, b) >< [] => a~(*L)[], b~(*R)[];
-Part(int x, a, b) >< (int y):ys
-| y<x => b~(*R)(y:cnt), (*L)Part(x, a, cnt)~ys
-| _ => a~(*R)(y:cnt), (*L)Part(x, cnt, b)~ys;
+part(int x, a, b) >< [] => a~(*L)[], b~(*R)[];
+part(int x, a, b) >< (int y):ys
+| y<x => b~(*R)(y:cnt), (*L)part(x, a, cnt)~ys
+| _ => a~(*R)(y:cnt), (*L)part(x, cnt, b)~ys;
-const LIST_ELEM=800000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-QS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=800000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+qsort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/qsort-800000.in b/comparison/Inpla/src/qsort-800000.in
index 8226655..6d28245 100644
--- a/comparison/Inpla/src/qsort-800000.in
+++ b/comparison/Inpla/src/qsort-800000.in
@@ -1,26 +1,44 @@
// Quick sort
-QS(ret) >< [] => ret~[];
-QS(ret) >< (int x):xs =>
- Part(x, left, right)~xs,
- QS(cntl)~left, QS(cntr)~right,
+qsort(ret) >< [] => ret~[];
+qsort(ret) >< (int x):xs =>
+ part(x, left, right)~xs,
+ qsort(cntl)~left, qsort(cntr)~right,
Append(ret, x:cntl)~cntr;
// Note: `Append' is implemented as built-in.
-Part(int x, a, b) >< [] => a~[], b~[];
-Part(int x, a, b) >< (int y):ys
-| y<x => b~(y:cnt), Part(x, a, cnt)~ys
-| _ => a~(y:cnt), Part(x, cnt, b)~ys;
+part(int x, a, b) >< [] => a~[], b~[];
+part(int x, a, b) >< (int y):ys
+| y<x => b~(y:cnt), part(x, a, cnt)~ys
+| _ => a~(y:cnt), part(x, cnt, b)~ys;
-const LIST_ELEM=800000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-QS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=800000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+qsort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/OCaml/bsort40000.ml b/comparison/OCaml/bsort40000.ml
index 45744bd..2a06e85 100644
--- a/comparison/OCaml/bsort40000.ml
+++ b/comparison/OCaml/bsort40000.ml
@@ -19,5 +19,17 @@ let rec mkRandList n =
0 -> []
| n -> (Random.int 10000)::(mkRandList (n-1));;
-let main = bsort (mkRandList 40000);;
+
+let rec validation alist =
+ let rec validation_cons x blist =
+ match blist with
+ [] -> true
+ | y::ys -> if x<=y then (validation_cons y ys) else false
+ in
+ match alist with
+ [] -> true
+ | x::xs -> validation_cons x xs;;
+
+
+let main = validation (bsort (mkRandList 40000));;
diff --git a/comparison/OCaml/isort40000.ml b/comparison/OCaml/isort40000.ml
index 686a7f6..92e127d 100644
--- a/comparison/OCaml/isort40000.ml
+++ b/comparison/OCaml/isort40000.ml
@@ -1,11 +1,3 @@
-(*
-let rec insert x ylist =
- match ylist with
- [] -> [x]
- | y::ys when x<=y -> x::y::ys
- | y::ys -> y::(insert x ys);;
-*)
-
let rec insert x ylist =
match ylist with
[] -> [x]
@@ -26,5 +18,17 @@ let rec mkRandList n =
0 -> []
| n -> (Random.int 10000)::(mkRandList (n-1));;
-let main = isort (mkRandList 40000);;
+
+let rec validation alist =
+ let rec validation_cons x blist =
+ match blist with
+ [] -> true
+ | y::ys -> if x<=y then (validation_cons y ys) else false
+ in
+ match alist with
+ [] -> true
+ | x::xs -> validation_cons x xs;;
+
+
+let main = validation(isort (mkRandList 40000));;
diff --git a/comparison/OCaml/msort800000.ml b/comparison/OCaml/msort800000.ml
index 1835b98..bbb8de6 100644
--- a/comparison/OCaml/msort800000.ml
+++ b/comparison/OCaml/msort800000.ml
@@ -33,11 +33,19 @@ let rec mkRandList n =
0 -> []
| n -> (Random.int 10000)::(mkRandList (n-1)) ;;
-let main = msort (mkRandList 800000) ;;
+let rec validation alist =
+ let rec validation_cons x blist =
+ match blist with
+ [] -> true
+ | y::ys -> if x<=y then (validation_cons y ys) else false
+ in
+ match alist with
+ [] -> true
+ | x::xs -> validation_cons x xs;;
-(*
-The following error arises:
+let main = validation (msort (mkRandList 800000));;
-Stack overflow during evaluation (looping recursion?).
+(*
+Fatal error: exception Stack_overflow
*)
diff --git a/comparison/OCaml/qsort800000.ml b/comparison/OCaml/qsort800000.ml
index 627abd2..7547f45 100644
--- a/comparison/OCaml/qsort800000.ml
+++ b/comparison/OCaml/qsort800000.ml
@@ -21,10 +21,20 @@ let rec mkRandList n =
0 -> []
| n -> (Random.int 10000)::(mkRandList (n-1)) ;;
-let main = qsort (mkRandList 800000) ;;
-(*
-The following error arises:
+let rec validation alist =
+ let rec validation_cons x blist =
+ match blist with
+ [] -> true
+ | y::ys -> if x<=y then (validation_cons y ys) else false
+ in
+ match alist with
+ [] -> true
+ | x::xs -> validation_cons x xs;;
+
-Stack overflow during evaluation (looping recursion?).
+let main = validation(qsort (mkRandList 800000));;
+
+(*
+Fatal error: exception Stack_overflow
*)
diff --git a/comparison/Python/bsort-40000.py b/comparison/Python/bsort-40000.py
index 25ea4c7..8eeb4e5 100644
--- a/comparison/Python/bsort-40000.py
+++ b/comparison/Python/bsort-40000.py
@@ -17,8 +17,15 @@ def mkRandList(n):
return a
-
+def validation(alist):
+ for i in range(len(alist)-1):
+ if (alist[i] > alist[i+1]):
+ return False
+
+ return True
+
+
+
a=mkRandList(40000)
bubblesort(a)
-
-#print(a)
+print(validation(a))
diff --git a/comparison/Python/isort-40000.py b/comparison/Python/isort-40000.py
index 0bfc577..c8e106b 100644
--- a/comparison/Python/isort-40000.py
+++ b/comparison/Python/isort-40000.py
@@ -17,6 +17,15 @@ def mkRandList(n):
a.insert(0, random.randint(0,10000))
return a
+
+def validation(alist):
+ for i in range(len(alist)-1):
+ if (alist[i] > alist[i+1]):
+ return False
+
+ return True
+
+
a = mkRandList(40000)
insert_sort(a)
-#print(a)
+print(validation(a))
diff --git a/comparison/Python/msort-800000.py b/comparison/Python/msort-800000.py
index fcb89e1..c244cb4 100644
--- a/comparison/Python/msort-800000.py
+++ b/comparison/Python/msort-800000.py
@@ -50,6 +50,15 @@ def mkRandList ( n ):
a.insert(0, random.randint(0,10000))
return a
+
+def validation(alist):
+ for i in range(len(alist)-1):
+ if (alist[i] > alist[i+1]):
+ return False
+
+ return True
+
+
a = mkRandList(800000)
mergeSort(a)
-#print(a)
+print(validation(a))
diff --git a/comparison/Python/qsort-800000.py b/comparison/Python/qsort-800000.py
index b58bf1c..a4a66e2 100644
--- a/comparison/Python/qsort-800000.py
+++ b/comparison/Python/qsort-800000.py
@@ -22,12 +22,22 @@ def quickSort(arr):
more = quickSort(more)
return less + pivotList + more
+
def mkRandList ( n ):
a=[]
for i in range(1,n+1):
a.insert(0, random.randint(0,10000))
return a
+
+def validation(alist):
+ for i in range(len(alist)-1):
+ if (alist[i] > alist[i+1]):
+ return False
+
+ return True
+
+
a = mkRandList(800000)
b = quickSort(a)
-#print(b)
+print(validation(b))
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));