diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-04-28 21:47:28 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-04-28 21:47:28 +0900 |
| commit | 7ea48cd96551247ecc763a5e42404ffa3464d0b0 (patch) | |
| tree | fd1b63ab48d98a9243d3053522e17e31b9dc033f /comparison/Inpla/src/bsort-40000-reuse.in | |
| parent | 950e2cb2184cb7ead93ba8df691a190598ed242f (diff) | |
| parent | 429543c748aaf81b2a4207318eb5a05259469b21 (diff) | |
| download | inpla-7ea48cd96551247ecc763a5e42404ffa3464d0b0.tar.gz inpla-7ea48cd96551247ecc763a5e42404ffa3464d0b0.zip | |
Merge branch 'develop'
Diffstat (limited to 'comparison/Inpla/src/bsort-40000-reuse.in')
| -rw-r--r-- | comparison/Inpla/src/bsort-40000-reuse.in | 35 |
1 files changed, 26 insertions, 9 deletions
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; |
