From 84584a949c4e9cf5215d119ca81c60913df0ea70 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Mon, 15 Jul 2019 20:55:41 -0700 Subject: [PATCH] Implement genrec combinator. --- thun/thun.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thun/thun.pl b/thun/thun.pl index 149dd66..ebc8b84 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -185,6 +185,10 @@ combo(times, [P, 1|S], S, Ei, Eo) :- append(P, Ei, Eo). combo(times, [P, N|S], S, Ei, Eo) :- N #>= 2, M #= N - 1, append(P, [M, P, times|Ei], Eo). combo(times, [_, N|S], S, _, _ ) :- N #< 0, fail. +combo(genrec, [R1, R0, Then, If|S], + [ Else, Then, If|S], E, [ifte|E]) :- + append(R0, [[If, Then, R0, R1, genrec]|R1], Else). + /* Compiler