summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/fivesix.adb23
1 files changed, 18 insertions, 5 deletions
diff --git a/test/fivesix.adb b/test/fivesix.adb
index a17cbb1..5876c44 100644
--- a/test/fivesix.adb
+++ b/test/fivesix.adb
@@ -23,7 +23,21 @@ procedure FiveSix is
package InPrin is new InKomp.Pretty_Print (Integer'Image);
use InPrin;
- Fives, Sixes : World := Empty_World;
+
+ -- It is possible to create a recursion using functions like this...
+ function Fives
+ (This : in World)
+ return World
+ is
+ One, Two : World := This;
+ begin
+ One.Unify (One.Fresh, 5);
+ Two.Conjunct (Fives'Access);
+ return Disjunct (One, Two);
+ end Fives;
+
+
+ Sixes : World := Empty_World;
Result : World;
begin
@@ -33,14 +47,13 @@ begin
TIO.New_Line;
- Fives.Unify (Fives.Fresh, 5);
- Fives.Recurse;
-
+ -- ...but it is a lot simpler and easier to create recursions this way instead.
Sixes.Unify (Sixes.Fresh, 6);
Sixes.Recurse;
- Result := Disjunct (Fives, Sixes);
+ Result := Disjunct (Fives (Empty_World), Sixes);
+ -- Note how the States from Fives keep creating new Variables instead of looping.
TIO.Put_Line (Image (Result.Take (5)));
end FiveSix;