From 9f1e75313bdabb5e691ff28cbe8b234d06657e61 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 14 Jul 2019 22:48:18 -0700 Subject: [PATCH] Reimplement app1 and app2 as definitions. This eliminates three recursive calls to thun/3. --- thun/thun.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thun/thun.pl b/thun/thun.pl index 227b1c4..6a4bb72 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -83,10 +83,6 @@ literal(_/_). Functions */ -func(app1, [P, Xi|S], [Xo|S]) :- thun(P, [Xi|S], [Xo|_]). % Combinator. -func(app2, [P, Xi, Yi|S], [Xo, Yo|S]) :- thun(P, [Xi|S], [Xo|_]), % Combinator. - thun(P, [Yi|S], [Yo|_]). - func(nullary, [P|S], [X|S]) :- thun(P, S, [X|_]). % Combinator. func(infra, [P, R|S], [Q|S]) :- thun(P, R, Q). % Combinator. @@ -145,6 +141,8 @@ r_truth(1, true). Definitions */ +app1 ≡ [grba, infra, first]. +app2 ≡ [[grba, swap, grba, swap], dip, [infra, first], cons, ii]. at ≡ [drop, first]. b ≡ [[i], dip, i]. binary ≡ [unary, popd]. @@ -156,7 +154,9 @@ dupd ≡ [[dup], dip]. dupdd ≡ [[dup], dipd]. fork ≡ [[i], app2]. fourth ≡ [rest, third]. +grba ≡ [[stack, popd], dip]. ifte ≡ [[nullary], dipd, swap, branch]. +ii ≡ [[dip], dupdip, i]. make_generator ≡ [[codireco], ccons]. neg ≡ [0, swap, -]. of ≡ [swap, at].