benchmark/tests/tak.sml
raw| 1 | fun tak (x,y,z) = |
| 2 | if not (y < x) |
| 3 | then z |
| 4 | else tak (tak (x - 1, y, z), |
| 5 | tak (y - 1, z, x), |
| 6 | tak (z - 1, x, y)) |
| 7 | |
| 8 | structure Main = |
| 9 | struct |
| 10 | fun doit n = |
| 11 | if n = 0 |
| 12 | then () |
| 13 | else let |
| 14 | val _ = if 22 <> tak (33,22,11) |
| 15 | then raise Fail "bug" |
| 16 | else () |
| 17 | in |
| 18 | doit (n - 1) |
| 19 | end |
| 20 | end |