14
15
16:- module(drs_reverse, [drs_reverse/2]). 17
18:- use_module(drs_ops).
37drs_reverse(drs([], []), drs([], [])) :- !.
38
39drs_reverse(drs(Dom, Conds), drs(DomR, CondsR)) :-
40 reverse(Dom, DomR),
41 reverse(Conds, Conds1),
42 conds_reverse(Conds1, CondsR).
52conds_reverse([], []).
53
54conds_reverse([First | Conds], [FirstR | CondsR]) :-
55 condition_reverse(First, FirstR),
56 conds_reverse(Conds, CondsR).
67condition_reverse(Drs, DrsR) :-
68 Drs =.. [Op, SubDrs],
69 unary_drs_operator(Op),
70 drs_reverse(SubDrs, SubDrsR),
71 !,
72 DrsR =.. [Op, SubDrsR].
73
74condition_reverse(Drs, DrsR) :-
75 Drs =.. [Op, SubDrs1, SubDrs2],
76 binary_drs_operator(Op),
77 drs_reverse(SubDrs1, SubDrs1R),
78 drs_reverse(SubDrs2, SubDrs2R),
79 !,
80 DrsR =.. [Op, SubDrs1R, SubDrs2R].
81
82condition_reverse([H|T], R) :-
83 reverse([H|T], R1),
84 conds_reverse(R1, R),
85 !.
86
87condition_reverse(Label:Drs, Label:DrsR) :-
88 drs_reverse(Drs, DrsR),
89 !.
90
91condition_reverse(Cond, Cond)
Reverse a DRS
*/