| 1 |
structure Main = |
| 2 |
struct |
| 3 |
fun doit n = |
| 4 |
let |
| 5 |
val v = Vector.tabulate (1000000, fn i => |
| 6 |
(Word14.fromInt i, |
| 7 |
Word10.fromInt (i + 1), |
| 8 |
Word8.fromInt (i + 2))) |
| 9 |
fun loop n = |
| 10 |
if 0 = n |
| 11 |
then () |
| 12 |
else |
| 13 |
let |
| 14 |
val sum = Vector.foldl (fn ((a, b, c), d) => |
| 15 |
Word14.toLarge a + |
| 16 |
Word10.toLarge b + |
| 17 |
Word8.toLarge c + d) 0wx0 v |
| 18 |
val _ = if 0wx20E0F3760 <> sum |
| 19 |
then raise Fail (LargeWord.toString sum) |
| 20 |
else () |
| 21 |
in |
| 22 |
loop (n - 1) |
| 23 |
end |
| 24 |
in |
| 25 |
loop n |
| 26 |
end |
| 27 |
end |
| 28 |
val _ = Main.doit 10 |