|
21147
|
1 |
structure ROOT =
|
|
|
2 |
struct
|
|
|
3 |
|
|
|
4 |
structure IntDef =
|
|
|
5 |
struct
|
|
|
6 |
|
|
|
7 |
datatype nat = Zero_nat | Succ_nat of nat;
|
|
|
8 |
|
|
|
9 |
fun plus_nat (Succ_nat m) n = plus_nat m (Succ_nat n)
|
|
|
10 |
| plus_nat Zero_nat y = y;
|
|
|
11 |
|
|
|
12 |
fun times_nat (Succ_nat m) n = plus_nat n (times_nat m n)
|
|
|
13 |
| times_nat Zero_nat na = Zero_nat;
|
|
|
14 |
|
|
|
15 |
end; (*struct IntDef*)
|
|
|
16 |
|
|
|
17 |
structure Codegen =
|
|
|
18 |
struct
|
|
|
19 |
|
|
|
20 |
fun fac n =
|
|
|
21 |
(case n of IntDef.Zero_nat => IntDef.Succ_nat IntDef.Zero_nat
|
|
|
22 |
| IntDef.Succ_nat ma => IntDef.times_nat n (fac ma));
|
|
|
23 |
|
|
|
24 |
end; (*struct Codegen*)
|
|
|
25 |
|
|
|
26 |
end; (*struct ROOT*)
|