diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-24 23:04:45 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-24 23:04:45 +0900 |
| commit | 787dc13c837f0955fbd85b8f26a05d720d361333 (patch) | |
| tree | fec3abebb1e867e8b2239d7cf07b4c7d13ce0f81 /comparison/Inpla/src/qsort-800000.in | |
| parent | e607a57dfafb784c4e27da143214afb2ccd07fbf (diff) | |
| download | inpla-787dc13c837f0955fbd85b8f26a05d720d361333.tar.gz inpla-787dc13c837f0955fbd85b8f26a05d720d361333.zip | |
Upload the comparison directory
Diffstat (limited to 'comparison/Inpla/src/qsort-800000.in')
| -rw-r--r-- | comparison/Inpla/src/qsort-800000.in | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/comparison/Inpla/src/qsort-800000.in b/comparison/Inpla/src/qsort-800000.in new file mode 100644 index 0000000..e8913e8 --- /dev/null +++ b/comparison/Inpla/src/qsort-800000.in @@ -0,0 +1,29 @@ +// Quick sort +QS(ret) >< [] => ret~[]; +QS(ret) >< (int x):xs => + Part(x, left, right)~xs, + QS(cntl)~left, QS(cntr)~right, + Append(ret, x:cntl)~cntr; + +// Note: `Append' is implemented as built-in. + +// Apnd(ret, a)~b --> ret ~ b@a +//Apnd(ret, a) >< [] => ret~a; +//Apnd(ret, a) >< x:xs => ret~(x:cnt), Apnd(cnt, a)~xs; + +Part(int x, a, b) >< [] => a~[], b~[]; +Part(int x, a, b) >< (int y):ys +| y<x => b~(y:cnt), Part(x, a, cnt)~ys +| _ => a~(y:cnt), Part(x, cnt, b)~ys; + + +const LIST_ELEM=800000; + +MkRandList(ret) >< (int n) +| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1) + where rd=rand(10000) +| _ => ret~[]; + +MkRandList(cnt)~(LIST_ELEM), +QS(ret)~cnt; +ret; |
