Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / benchmark / tests / vector-rev.sml
1 (* Written by Stephen Weeks (sweeks@sweeks.com). *)
2
3 structure Main =
4 struct
5 open Vector
6
7 fun rev v =
8 let
9 val n = length v
10 in
11 tabulate (n, fn i => sub (v, n - 1 - i))
12 end
13
14 fun doit n =
15 let
16 val v = tabulate (200000, fn i => i)
17 fun loop n =
18 if n < 0
19 then ()
20 else
21 if 0 = sub (rev (rev v), 0)
22 then loop (n - 1)
23 else raise Fail "bug"
24 in loop (n * 1000)
25 end
26 end