Import Upstream version 20180207
[hcoop/debian/mlton.git] / benchmark / tests / DATA / hamlet-input.sml
1 datatype t = Z | S of t;
2 val zero = Z;
3 val one = S zero;
4 val two = S one;
5 val rec add: t * t -> t = fn (Z, n) => n | (S m, n) => S (add (m, n));
6 val rec mul: t * t -> t = fn (Z, n) => Z | (S z, n) => add (n, mul (z, n));
7 val four = mul (two, two);
8 val rec exp: t * t -> t = fn (n, Z) => one | (n, S m) => mul (n, exp (n, m));
9 val _ = exp (exp (four, four), two);