--  A `while` clause in a quantified expression over a container whose iteration order the
--  library states: a vector by position, an ordered set by key.
pragma Extensions_Allowed (On);
with Ada.Text_IO; use Ada.Text_IO;
with Verada.Containers.Unbounded.Vectors;
with Verada.Containers.Unbounded.Ordered_Sets;
procedure Main is
   subtype Score is Integer range -100 .. 100;
   package V is new Verada.Containers.Unbounded.Vectors (Score);
   package P is new Verada.Containers.Unbounded.Ordered_Sets (Integer);
   use P;
   X : constant V.Vector := [3, 5, 0, -1];
   S : Set;

   --  every value before the first zero is positive
   function Leading_Positive (C : V.Vector) return Boolean is
     (for all E of C while E /= 0 => E > 0);

   --  the members below 10 are not negative
   function Small_Not_Negative (C : Set) return Boolean is
     (for all E of C while E < 10 => E >= 0);
begin
   pragma Assert (for all E of X while E /= 0 => E > 0);
   pragma Assert (not (for some E of X while E /= 0 => E = -1));
   Include (S, 12);
   Include (S, 3);
   Put_Line (Boolean'Image (Leading_Positive (X)) & " " & Boolean'Image (Leading_Positive ([1, -2, 0])) & " " & Boolean'Image (Small_Not_Negative (S)));
   Include (S, -4);
   Put_Line (Boolean'Image (Small_Not_Negative (S)));
end Main;
