diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-09-17 22:25:50 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-09-17 22:25:50 +0900 |
| commit | d90c10cd95e399dd7614df76ee06acd1bf721833 (patch) | |
| tree | 42fd557836de39d4a32a303c40f42393906a6e4c /comparison/Inpla | |
| parent | 4b0da2732d7adcaa7d85db2ee329f8a52ef88c42 (diff) | |
| parent | b10fccefe9a6435328ff9d554995fb5710f74f26 (diff) | |
| download | inpla-d90c10cd95e399dd7614df76ee06acd1bf721833.tar.gz inpla-d90c10cd95e399dd7614df76ee06acd1bf721833.zip | |
Merge branch 'develop'
Diffstat (limited to 'comparison/Inpla')
| -rw-r--r-- | comparison/Inpla/src/ack-stream_3-11-reuse.in | 6 | ||||
| -rw-r--r-- | comparison/Inpla/src/bsort-20000-reuse.in | 28 | ||||
| -rw-r--r-- | comparison/Inpla/src/bsort-20000.in | 10 | ||||
| -rw-r--r-- | comparison/Inpla/src/fib-38-reuse.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/isort-20000-reuse.in | 6 | ||||
| -rw-r--r-- | comparison/Inpla/src/msort-260000-reuse.in | 3 | ||||
| -rw-r--r-- | comparison/Inpla/src/msort-800000-reuse.in | 5 | ||||
| -rw-r--r-- | comparison/Inpla/src/msort-800000.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/qsort-260000-reuse.in | 5 | ||||
| -rw-r--r-- | comparison/Inpla/src/qsort-800000-reuse.in | 7 | ||||
| -rw-r--r-- | comparison/Inpla/src/qsort-800000.in | 2 |
11 files changed, 32 insertions, 44 deletions
diff --git a/comparison/Inpla/src/ack-stream_3-11-reuse.in b/comparison/Inpla/src/ack-stream_3-11-reuse.in index 7d7c701..4a05f82 100644 --- a/comparison/Inpla/src/ack-stream_3-11-reuse.in +++ b/comparison/Inpla/src/ack-stream_3-11-reuse.in @@ -24,7 +24,7 @@ Ack(ret, n) >< (int m) | _ => (*L)Ackm(ret, m)~n; Ackm(ret, int m) >< (int n) -| n==0 => Ack(ret,Inc(0)) ~ (m-1) +| n==0 => (*L)Ack(ret,Inc(0)) ~ (m-1) | _ => (*L)Ack(cnt,n-1)~m, Ack(ret,cnt)~(m-1); Ackm(ret, int m) >< Inc(n) @@ -34,8 +34,8 @@ Sumup(ret, int sum) >< Inc(x) => (*L)Sumup(ret, sum+1)~x; Sumup(ret, int sum) >< (int n) => ret~sum+n; -//AckMain(ret)><(int m, int n) => (*L)Ack(cnt,n)~m, (*R)Sumup(ret,0)~cnt; -AckMain(ret)><(int m, int n) => Ack(cnt,n)~m, Sumup(ret,0)~cnt; +AckMain(ret)><(int m, int n) => (*L)Ack(cnt,n)~m, (*R)Sumup(ret,0)~cnt; +//AckMain(ret)><(int m, int n) => Ack(cnt,n)~m, Sumup(ret,0)~cnt; AckMain(ret)~(3,11); ret; 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; diff --git a/comparison/Inpla/src/bsort-20000.in b/comparison/Inpla/src/bsort-20000.in index e012bc6..8beb835 100644 --- a/comparison/Inpla/src/bsort-20000.in +++ b/comparison/Inpla/src/bsort-20000.in @@ -1,15 +1,5 @@ // 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~[]; len_stream_(len, list, int ct) >< x:xs => diff --git a/comparison/Inpla/src/fib-38-reuse.in b/comparison/Inpla/src/fib-38-reuse.in index e56fabd..c95127e 100644 --- a/comparison/Inpla/src/fib-38-reuse.in +++ b/comparison/Inpla/src/fib-38-reuse.in @@ -2,7 +2,7 @@ Fib(r) >< (int n) | n == 0 => r~0 | n == 1 => r~1 -| _ => Fib(cnt1)~(n-1), Fib(cnt2)~(n-2), (*L)Add(r,cnt2)~cnt1; +| _ => (*L)Fib(cnt1)~(n-1), Fib(cnt2)~(n-2), Add(r,cnt2)~cnt1; Fib(r)~38; diff --git a/comparison/Inpla/src/isort-20000-reuse.in b/comparison/Inpla/src/isort-20000-reuse.in index 9d7c7ab..aa63652 100644 --- a/comparison/Inpla/src/isort-20000-reuse.in +++ b/comparison/Inpla/src/isort-20000-reuse.in @@ -1,11 +1,11 @@ // Insertion sort -isort(ret) >< [] => ret~[]; -isort(ret) >< x:xs => (*L)I(ret, x)~cnt, (*R)isort(cnt)~xs; +isort(ret) >< [] => ret~(*R)[]; +isort(ret) >< x:xs => (*R)I(ret, x)~cnt, (*L)isort(cnt)~xs; I(ret, int x) >< [] => ret~[x]; I(ret, int x) >< (int y):ys | x<=y => ret~(*L)(x:(*R)(y:ys)) -| _ => ret~(*L)(y:cnt), (*R)I(cnt, x)~ys; +| _ => (*L)I(cnt, x)~ys, ret~(*R)(y:cnt); // creates a random list diff --git a/comparison/Inpla/src/msort-260000-reuse.in b/comparison/Inpla/src/msort-260000-reuse.in index 7201ac7..14aa4a3 100644 --- a/comparison/Inpla/src/msort-260000-reuse.in +++ b/comparison/Inpla/src/msort-260000-reuse.in @@ -4,7 +4,7 @@ msort(ret) >< x:xs => (*L)msort_tail(ret, x)~xs; msort_tail(ret, int n) >< [] => ret~[n]; msort_tail(ret, int n) >< x:xs => - split(left,right) ~ (*R)(n:x:xs), + split(left,right) ~ n:(*R)(x:xs), msort(a)~left, msort(b)~right, (*L)merge(ret,b)~a; merge(ret, snd) >< [] => ret~snd; @@ -15,7 +15,6 @@ 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; diff --git a/comparison/Inpla/src/msort-800000-reuse.in b/comparison/Inpla/src/msort-800000-reuse.in index 4572623..f50f359 100644 --- a/comparison/Inpla/src/msort-800000-reuse.in +++ b/comparison/Inpla/src/msort-800000-reuse.in @@ -4,7 +4,7 @@ msort(ret) >< x:xs => (*L)msort_tail(ret, x)~xs; msort_tail(ret, int n) >< [] => ret~[n]; msort_tail(ret, int n) >< x:xs => - split(left,right) ~ (*R)(n:x:xs), + split(left,right) ~ n:(*R)(x:xs), msort(a)~left, msort(b)~right, (*L)merge(ret,b)~a; merge(ret, snd) >< [] => ret~snd; @@ -15,7 +15,6 @@ 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; @@ -29,7 +28,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/msort-800000.in b/comparison/Inpla/src/msort-800000.in index 3c43aa6..ab330a8 100644 --- a/comparison/Inpla/src/msort-800000.in +++ b/comparison/Inpla/src/msort-800000.in @@ -29,7 +29,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/qsort-260000-reuse.in b/comparison/Inpla/src/qsort-260000-reuse.in index b44e958..33cd7dc 100644 --- a/comparison/Inpla/src/qsort-260000-reuse.in +++ b/comparison/Inpla/src/qsort-260000-reuse.in @@ -5,6 +5,7 @@ qsort(ret) >< (int x):xs => (*L)qsort(cntl)~left, qsort(cntr)~right, Append(ret, x:cntl)~cntr; + // Note: `Append' is implemented as built-in. @@ -12,6 +13,10 @@ 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; +//| y<x => (*L)part(x, a, cnt)~ys, b~(*R)(y:cnt) // quite BAD! +//| _ => (*L)part(x, cnt, b)~ys, a~(*R)(y:cnt); // quite BAD! + + // creates a random list diff --git a/comparison/Inpla/src/qsort-800000-reuse.in b/comparison/Inpla/src/qsort-800000-reuse.in index 7f41045..b1e2ae1 100644 --- a/comparison/Inpla/src/qsort-800000-reuse.in +++ b/comparison/Inpla/src/qsort-800000-reuse.in @@ -5,6 +5,7 @@ qsort(ret) >< (int x):xs => (*L)qsort(cntl)~left, qsort(cntr)~right, Append(ret, x:cntl)~cntr; + // Note: `Append' is implemented as built-in. @@ -12,6 +13,10 @@ 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; +//| y<x => (*L)part(x, a, cnt)~ys, b~(*R)(y:cnt) // quite BAD! +//| _ => (*L)part(x, cnt, b)~ys, a~(*R)(y:cnt); // quite BAD! + + // creates a random list @@ -22,7 +27,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/qsort-800000.in b/comparison/Inpla/src/qsort-800000.in index 6d28245..e1b9071 100644 --- a/comparison/Inpla/src/qsort-800000.in +++ b/comparison/Inpla/src/qsort-800000.in @@ -22,7 +22,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; |
