pragma Extensions_Allowed (On);
--  a matrix walked in step with arrays, ranges and matrices, and a while clause (Verada's extensions) (T32a)
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   subtype Small is Integer range -100 .. 100;
   type Matrix is array (Positive range <>, Positive range <>) of Small;
   type Vector is array (Positive range <>) of Small;
   function Dot (M : Matrix; V : Vector) return Integer
     with Pre => M'Length (1) <= 10 and M'Length (2) <= 10
   is
      S : Integer := 0;
   begin
      for E of M, X of V loop
         if S in -1_000_000 .. 1_000_000 then
            S := S + E * X;
         end if;
      end loop;
      return S;
   end Dot;
   P : constant Matrix := ((1, 2, 3), (4, 5, 6));
   Q : constant Matrix := ((10, 20), (30, 40), (50, 60));
   V : constant Vector := (1, 1, 1, 1, 1);
begin
   for E of P while E < 5 loop
      Put (Integer'Image (E));
   end loop;
   New_Line;
   for E of P, F of Q loop
      Put (Integer'Image (E * F));
   end loop;
   New_Line;
   for I in 1 .. 4, E of Q loop
      Put (Integer'Image (I) & ":" & Integer'Image (E));
   end loop;
   New_Line;
   for X of V, E of P loop
      Put (Integer'Image (X + E));
   end loop;
   New_Line;
   Put_Line (Integer'Image (Dot (P, V)));
end Main;
