aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2026-02-06 17:19:26 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2026-02-06 17:19:26 +1300
commit6bced91bd28f860d830dfda921ee5056ec93f48c (patch)
treea91432226dbf11ed944cfe50507e0b7a03870bd2 /test
parent9b964acdb0cc36d09193861b8f7d33aea248ee46 (diff)
Evaluation algorithm changed to inverted interleaved depth first search
Diffstat (limited to 'test')
-rw-r--r--test/fivesix.adb28
-rw-r--r--test/repeat.adb46
2 files changed, 17 insertions, 57 deletions
diff --git a/test/fivesix.adb b/test/fivesix.adb
index 9620c60..781b7c3 100644
--- a/test/fivesix.adb
+++ b/test/fivesix.adb
@@ -24,7 +24,6 @@ procedure FiveSix is
use InPrin;
- -- It is possible to create a recursion using functions like this...
function Fives
(This : in Goal)
return Goal
@@ -36,9 +35,19 @@ procedure FiveSix is
return Disjunct (One, Two);
end Fives;
+ function Sixes
+ (This : in Goal)
+ return Goal
+ is
+ One, Two : Goal := This;
+ begin
+ One.Unify (One.Fresh, 6);
+ Two.Conjunct (Sixes'Access);
+ return Disjunct (One, Two);
+ end Sixes;
+
- Sixes : Goal := Empty_Goal;
- Result : Goal;
+ Relation : constant Goal := Disjunct (Fives (Empty_Goal), Sixes (Empty_Goal));
begin
@@ -47,14 +56,11 @@ begin
TIO.New_Line;
- -- ...but it is a lot simpler and easier to create recursions this way instead.
- Sixes.Unify (Sixes.Fresh, 6);
- Sixes.Recurse;
-
- Result := Disjunct (Fives (Empty_Goal), Sixes);
-
- -- Note how the States from Fives keep creating new Variables instead of looping.
- TIO.Put_Line (Image (Result.Run (5)));
+ -- Note how the States keep using new Variables instead of just reusing the same one.
+ -- This is an unavoidable side effect of setting up Variable Terms to be manually
+ -- created from a Goal by the programmer, instead of being supplied as needed in the
+ -- process of evaluation.
+ TIO.Put_Line (Image (Relation.Run (5)));
end FiveSix;
diff --git a/test/repeat.adb b/test/repeat.adb
deleted file mode 100644
index 0eec066..0000000
--- a/test/repeat.adb
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
--- Programmed by Jedidiah Barber
--- Licensed under the Sunset License v1.0
-
--- See license.txt for further details
-
-
-with
-
- Ada.Text_IO,
- Kompsos.Pretty_Print;
-
-
-procedure Repeat is
-
- package TIO renames Ada.Text_IO;
-
-
- package InKomp is new Kompsos (Integer);
- use InKomp;
-
- package Printer is new InKomp.Pretty_Print (Integer'Image);
-
-
- Relation : Goal := Empty_Goal;
-
- A : constant Term := Relation.Fresh;
- B : constant Term := Relation.Fresh;
-
-begin
-
- TIO.Put_Line ("Test program to check whether Recurse is working properly.");
- TIO.Put_Line ("There should be 5 results, all identical.");
-
- TIO.New_Line;
-
- Relation := Disjunct (Relation.Unify (A, 1), Relation.Unify (B, 2));
- Relation.Unify (A, 3);
- Relation.Recurse;
-
- TIO.Put_Line (Printer.Image (Relation.Run (5)));
-
-end Repeat;
-
-