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