From 787dc13c837f0955fbd85b8f26a05d720d361333 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sun, 24 Oct 2021 23:04:45 +0900 Subject: Upload the comparison directory --- comparison/Inpla/src/qsort-800000-reuse.in | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 comparison/Inpla/src/qsort-800000-reuse.in (limited to 'comparison/Inpla/src/qsort-800000-reuse.in') diff --git a/comparison/Inpla/src/qsort-800000-reuse.in b/comparison/Inpla/src/qsort-800000-reuse.in new file mode 100644 index 0000000..8bf7a83 --- /dev/null +++ b/comparison/Inpla/src/qsort-800000-reuse.in @@ -0,0 +1,29 @@ +// Quick sort +QS(ret) >< [] => ret~(*R)[]; +QS(ret) >< (int x):xs => + (*R)Part(x, left, right)~xs, + (*L)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~(*L)[], b~(*R)[]; +Part(int x, a, b) >< (int y):ys +| y b~(*R)(y:cnt), (*L)Part(x, a, cnt)~ys +| _ => a~(*R)(y:cnt), (*L)Part(x, cnt, b)~ys; + + +const LIST_ELEM=800000; + +MkRandList(ret) >< (int n) +| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1) + where rd=rand(10000) +| _ => ret~[]; + +MkRandList(cnt)~(LIST_ELEM), +QS(ret)~cnt; +ret; -- cgit v1.2.3