21147
|
1 |
structure ROOT =
|
|
2 |
struct
|
|
3 |
|
|
4 |
structure Code_Generator =
|
|
5 |
struct
|
|
6 |
|
|
7 |
type 'a eq = {eq_ : 'a -> 'a -> bool};
|
21190
|
8 |
fun eq (A_:'a eq) = #eq_ A_;
|
21147
|
9 |
|
|
10 |
end; (*struct Code_Generator*)
|
|
11 |
|
|
12 |
structure HOL =
|
|
13 |
struct
|
|
14 |
|
21190
|
15 |
fun op_eq (A_:'a Code_Generator.eq) a b = Code_Generator.eq A_ a b;
|
21147
|
16 |
|
|
17 |
end; (*struct HOL*)
|
|
18 |
|
|
19 |
structure List =
|
|
20 |
struct
|
|
21 |
|
|
22 |
fun memberl (A_1_:'a_1 Code_Generator.eq) x (y :: ys) =
|
|
23 |
HOL.op_eq A_1_ x y orelse memberl A_1_ x ys
|
21172
|
24 |
| memberl (A_1_:'a_1 Code_Generator.eq) x [] = false;
|
21147
|
25 |
|
|
26 |
end; (*struct List*)
|
|
27 |
|
|
28 |
structure Codegen =
|
|
29 |
struct
|
|
30 |
|
|
31 |
fun collect_duplicates (A_:'a Code_Generator.eq) xs ys (z :: zs) =
|
|
32 |
(if List.memberl A_ z xs
|
|
33 |
then (if List.memberl A_ z ys then collect_duplicates A_ xs ys zs
|
|
34 |
else collect_duplicates A_ xs (z :: ys) zs)
|
|
35 |
else collect_duplicates A_ (z :: xs) (z :: ys) zs)
|
21172
|
36 |
| collect_duplicates (A_:'a Code_Generator.eq) y ys [] = y;
|
21147
|
37 |
|
|
38 |
end; (*struct Codegen*)
|
|
39 |
|
|
40 |
end; (*struct ROOT*)
|