aboutsummaryrefslogtreecommitdiff
path: root/comparison/Inpla/src/bsort-40000.in
blob: d0a5e1cce7795fee085f419277da9533651a3f25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Bubble sort
BS(ret) >< [] => ret~[];
BS(ret) >< x:xs => BS(ret)~cnt, B(cnt, x)~xs;
BS(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~(x:cnt), B(cnt, y)~ys
| _   => ret~(y:cnt), B(cnt, x)~ys;



const LIST_ELEM=40000;

MkRandList(ret) >< (int n)
| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1) 
  where rd=rand(10000)
| _ => ret~[];

MkRandList(cnt)~(LIST_ELEM),
BS(ret)~cnt;
ret;