From ae769d2341943187882ba31feb73c413e6597ecf Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 20 Jul 2019 17:36:58 -0700 Subject: [PATCH] Fold try_both_branches/4 into branch combo. --- thun/thun.pl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/thun/thun.pl b/thun/thun.pl index 56e7fd1..2a14707 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -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 */