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/msort-800000.in | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 comparison/Inpla/src/msort-800000.in (limited to 'comparison/Inpla/src/msort-800000.in') diff --git a/comparison/Inpla/src/msort-800000.in b/comparison/Inpla/src/msort-800000.in new file mode 100644 index 0000000..e04803f --- /dev/null +++ b/comparison/Inpla/src/msort-800000.in @@ -0,0 +1,34 @@ +// Merge sort +MS(ret) >< [] => ret~[]; +MS(ret) >< x:xs => MS_tail(ret, x)~xs; + +MS_tail(ret, int n) >< [] => ret~[n]; +MS_tail(ret, int n) >< x:xs => + Split(left,right) ~ (n:x:xs), + MS(a)~left, MS(b)~right, Merge(ret,b)~a; + +Merge(ret, snd) >< [] => ret~snd; +Merge(ret, snd) >< x:xs => MergeC(ret, x, xs)~snd; + +MergeCC(ret, int y, ys) >< [] => ret~(y:ys); +MergeCC(ret, int y, ys) >< (int x):xs +| x <= y => ret~(x:cnt), MergeCC(cnt, y, ys) ~ xs +| _ => ret~(y:cnt), MergeCC(cnt, x, xs) ~ ys; + + +Split(right,left) >< [] => right~[], left~[]; +Split(right,left) >< x:xs => + right~(x:cntl), left~cntr, Split(cntr,cntl)~xs; + + + +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), +MS(ret)~cnt; +ret; -- cgit v1.2.3