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)
|
22751
|
10 |
| plus_nat Zero_nat n = n;
|
21147
|
11 |
|
21994
|
12 |
fun times_nat (Suc m) n = plus_nat n (times_nat m n)
|
|
13 |
| times_nat Zero_nat n = Zero_nat;
|
21147
|
14 |
|
21190
|
15 |
end; (*struct Nat*)
|
21147
|
16 |
|
|
17 |
structure Codegen =
|
|
18 |
struct
|
|
19 |
|
21994
|
20 |
fun fac (Nat.Suc n) = Nat.times_nat (Nat.Suc n) (fac n)
|
|
21 |
| fac Nat.Zero_nat = Nat.Suc Nat.Zero_nat;
|
21147
|
22 |
|
|
23 |
end; (*struct Codegen*)
|
|
24 |
|
|
25 |
end; (*struct ROOT*)
|