with Ada.Text_IO; use Ada.Text_IO;
with Verada.Optionals;
with Stats; use Stats;

procedure Main is
   Class : constant Scores := (72, 45, 100, 88, 61, 39, 95);
   High : constant Scores := Above (Class, 80);
   Fair : constant Scores := Curved (Class);
   --  find: the first and last score above a mark, through Verada.Optionals' reducers
   package Score_Options is new Verada.Optionals (Score);
   use Score_Options;
   First_High : constant Optional := [for S of Class when S > 80 => Just (S)]'Reduce (Keep_First, None);
   Last_Low : constant Optional := [for S of Class when S < 50 => Just (S)]'Reduce (Keep_Last, None);
begin
   Put_Line ("total" & Integer'Image (Total (Class)) & Integer'Image (Running_Total (Class)));
   Put_Line ("passing" & Integer'Image (Passing (Class, 60)) & Integer'Image (Passing_Total (Class, 60)));
   Put_Line ("squares" & Integer'Image (Sum_Of_Squares (10)));
   Put_Line ("best" & Integer'Image (Best (Class)));
   Put_Line ("valid " & Boolean'Image (All_Valid (Class)) & ", perfect " & Boolean'Image (Any_Perfect (Class)));
   Put ("above 80:");
   for S of High loop
      Put (Integer'Image (S));
   end loop;
   New_Line;
   if Has_Value (First_High) and Has_Value (Last_Low) then
      Put_Line ("first above 80" & Integer'Image (Value (First_High)) & ", last below 50" & Integer'Image (Value (Last_Low)));
   end if;
   Put ("curved:");
   for S of Fair loop
      Put (Integer'Image (S));
   end loop;
   New_Line;
end Main;
