aboutsummaryrefslogtreecommitdiff
path: root/comparison/Inpla/src/bsort-20000-reuse.in
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2022-09-17 22:25:32 +0900
committerShinya Sato <shinnya.sato@gmail.com>2022-09-17 22:25:32 +0900
commitb10fccefe9a6435328ff9d554995fb5710f74f26 (patch)
tree42fd557836de39d4a32a303c40f42393906a6e4c /comparison/Inpla/src/bsort-20000-reuse.in
parent6077933906dd637af93adb3714b476ccba724be1 (diff)
downloadinpla-b10fccefe9a6435328ff9d554995fb5710f74f26.tar.gz
inpla-b10fccefe9a6435328ff9d554995fb5710f74f26.zip
v0.10.0
Diffstat (limited to 'comparison/Inpla/src/bsort-20000-reuse.in')
-rw-r--r--comparison/Inpla/src/bsort-20000-reuse.in28
1 files changed, 9 insertions, 19 deletions
diff --git a/comparison/Inpla/src/bsort-20000-reuse.in b/comparison/Inpla/src/bsort-20000-reuse.in
index c5080fe..0b7e551 100644
--- a/comparison/Inpla/src/bsort-20000-reuse.in
+++ b/comparison/Inpla/src/bsort-20000-reuse.in
@@ -1,26 +1,16 @@
// Bubble sort with the same algorithm as others
-/*
-// length
-length_(r,n) >< [] => r~n;
-length_(r,int n) >< (int x):xs => length_(r,n+1)~xs;
-
-length(r) >< [] => r~0;
-length(r) >< x:xs => length_(r,0) ~ x:xs;
-*/
-
-
// stream length
len_stream_(len, list, int ct) >< [] => len~ct, list~(*R)[];
len_stream_(len, list, int ct) >< x:xs =>
list~(*R)(x:cnt),
- len_stream_(len, cnt, ct+1) ~ xs;
+ (*L)len_stream_(len, cnt, ct+1) ~ xs;
len_stream(len, list) >< [] => len~0, list~(*R)[];
len_stream(len, list) >< x:xs =>
- list~(x:cnt),
- len_stream_(len, cnt, 1)~xs;
+ list~(*R)(x:cnt),
+ (*L)len_stream_(len, cnt, 1)~xs;
// bubble sort
@@ -32,18 +22,18 @@ bs_Cons(r, int n)>< x:xs => (*L)bs_ConsCons(r, n, x) ~ xs;
bs_Cons(r, int n)>< [] => r~(*R)[];
bs_ConsCons(r, int n, int x) >< (int y):ys
-| x < y => r~x:cnt, (*L)bs(cnt, y:ys) ~(n-1)
-| _ => r~y:cnt, (*L)bs(cnt, x:ys)~(n-1);
+| x < y => r~x:cnt, (*L)bs(cnt, (*R)(y:ys)) ~(n-1)
+| _ => r~y:cnt, (*L)bs(cnt, (*R)(x:ys))~(n-1);
bs_ConsCons(r, int n, int x) >< [] => r~(*R)[x];
go(r,xs) >< (int n)
| n==0 => r~xs
-| _ => bs(cnt, xs)~n, (*L)go(r, cnt)~(n-1);
+| _ => (*L)bs(cnt, xs)~n, go(r, cnt)~(n-1);
-bsort(r) >< [] => r~[];
+bsort(r) >< [] => r~(*R)[];
bsort(r) >< x:xs =>
- (*L)len_stream(len, alist) ~ (*R)(x:xs),
- go(r, alist)~lengthDec1,
+ len_stream(len, alist) ~ (*R)(x:xs),
+ (*L)go(r, alist)~lengthDec1,
Sub(lengthDec1,len)~1;