From b10fccefe9a6435328ff9d554995fb5710f74f26 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sat, 17 Sep 2022 22:25:32 +0900 Subject: v0.10.0 --- comparison/Inpla/src/bsort-20000-reuse.in | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'comparison/Inpla/src/bsort-20000-reuse.in') 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; -- cgit v1.2.3