Fold try_both_branches/4 into branch combo.

This commit is contained in:
Simon Forman 2019-07-20 17:36:58 -07:00
parent 230288c02c
commit ae769d2341
1 changed files with 3 additions and 7 deletions

View File

@ -208,10 +208,10 @@ combo(dupdip, [P, X|S], [X|S], Ei, Eo) :- append(P, [X|Ei], Eo).
combo(branch, [T, _, true|S], S, Ei, Eo) :- !, append(T, Ei, Eo).
combo(branch, [_, F, false|S], S, Ei, Eo) :- !, append(F, Ei, Eo).
combo(branch, [T, F, Expr|S], S, Ei, Eo) :-
catch(
catch( % Try Expr and do one or the other,
(Expr -> append(T, Ei, Eo) ; append(F, Ei, Eo)),
_,
try_both_branches(T, F, Ei, Eo) % in case of error.
_, % If Expr don't grok, try both branches.
(append(T, Ei, Eo) ; append(F, Ei, Eo))
).
@ -233,10 +233,6 @@ combo(genrec, [R1, R0, Then, If|S],
append(R0, [Quoted|R1], Else).
try_both_branches(T, _, Ei, Eo) :- append(T, Ei, Eo).
try_both_branches(_, F, Ei, Eo) :- append(F, Ei, Eo).
/*
Compiler
*/