diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:38 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-05-30 20:36:38 +0900 |
| commit | e18b27f43ac23689822d4aaaaa3e8d550e41017a (patch) | |
| tree | 262150d7ad6abc6759f41a7adbb6dec4a7c90cb5 /comparison/Inpla/src/bsort-efficient-20000-reuse.in | |
| parent | 04cbbcc0649dfc80d8dbf8c4bc567285df7a9da4 (diff) | |
| download | inpla-e18b27f43ac23689822d4aaaaa3e8d550e41017a.tar.gz inpla-e18b27f43ac23689822d4aaaaa3e8d550e41017a.zip | |
v0.8.2-2
Diffstat (limited to 'comparison/Inpla/src/bsort-efficient-20000-reuse.in')
| -rw-r--r-- | comparison/Inpla/src/bsort-efficient-20000-reuse.in | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/comparison/Inpla/src/bsort-efficient-20000-reuse.in b/comparison/Inpla/src/bsort-efficient-20000-reuse.in new file mode 100644 index 0000000..e496c3e --- /dev/null +++ b/comparison/Inpla/src/bsort-efficient-20000-reuse.in @@ -0,0 +1,40 @@ +// Bubble sort +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); +B(ret, int x) >< (int y):ys +| x<y => ret~(*R)(x:cnt), (*L)B(cnt, 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~True; +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=20000; + +make_RandList(rndlist)~(LIST_ELEM), +bsort(sorted)~rndlist, +valid(ret)~sorted; + +ret; |
