diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-12-17 09:44:49 +1300 |
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-12-17 09:44:49 +1300 |
| commit | 2ec591d4b2b4dc11356b7bc5f261050b2c49fed9 (patch) | |
| tree | a5f9bea9595518c27740dc8e356f27170f70ca29 | |
| parent | 49ce64ee1e086df3b84ebd60507f3b3547a5bf0e (diff) | |
Fivesix now tests manual recursion using Conjunct as well as the Recurse subprogram
| -rw-r--r-- | test/fivesix.adb | 23 |
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; |
