From 7719622ff4f72769f15a771dc5455dabeff295bc Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Mon, 10 Nov 2025 18:57:08 +1300 Subject: Infinite number of States in a World enabled with lazy evaluation --- src/kompsos-pretty_print.adb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/kompsos-pretty_print.adb') diff --git a/src/kompsos-pretty_print.adb b/src/kompsos-pretty_print.adb index d1d89b8..62f27fa 100644 --- a/src/kompsos-pretty_print.adb +++ b/src/kompsos-pretty_print.adb @@ -124,14 +124,18 @@ package body Kompsos.Pretty_Print is (Item : in World) return String is - Result : SU.Unbounded_String; + Result : SU.Unbounded_String; + Scratch : World := Item; + Counter : Positive := 1; begin - if Item.Possibles.Is_Empty then + if not Scratch.Has_State (Counter) then return "States: N/A" & Latin.LF; end if; - for Index in Integer range Item.Possibles.First_Index .. Item.Possibles.Last_Index loop - SU.Append (Result, "State#" & Image (Index) & ":" & Latin.LF); - SU.Append (Result, Image (Item.Possibles.Constant_Reference (Index))); + loop + SU.Append (Result, "State#" & Image (Counter) & ":" & Latin.LF); + SU.Append (Result, Image (Scratch.Possibles.Constant_Reference (Counter))); + Counter := Counter + 1; + exit when not Scratch.Has_State (Counter); end loop; return SU.Slice (Result, 1, SU.Length (Result) - 1); end Image; -- cgit