pragma Extensions_Allowed (On);
--  APL text (T32b): ravel and reshape, in row-major order, proved
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   subtype Small is Integer range -100 .. 100;
   type Vector is array (Positive range <>) of Integer;
   type Smalls is array (Positive range <>) of Small;
   type Matrix is array (Positive range <>, Positive range <>) of Small;
   type Grid is array (Positive range <>, Positive range <>) of Integer;
   X : constant Smalls := (1, 2, 3, 4, 5, 6);
   A : constant Matrix := ((1, 2, 3), (4, 5, 6));
   procedure Show (V : Vector) is
   begin
      for E of V loop
         Put (Integer'Image (E));
      end loop;
      New_Line;
   end Show;
   procedure Show (G : Grid) is
   begin
      for I in G'Range (1) loop
         for J in G'Range (2) loop
            Put (Integer'Image (G (I, J)));
         end loop;
         Put (" |");
      end loop;
      New_Line;
   end Show;
   Flat : constant Vector := APL (", A");
   Flat_T : constant Vector := APL (", ⍉ A");
   Three_By_Two : constant Grid := APL ("3 2 ⍴ X");
   Cycled : constant Grid := APL ("2 4 ⍴ 1 2 3");
   Same : constant Grid := APL ("(⍴ A) ⍴ , A");
   Long : constant Vector := APL ("8 ⍴ X");
begin
   Show (Flat);
   Show (Flat_T);
   Show (Three_By_Two);
   Show (Cycled);
   Show (Same);
   Show (Long);
end Main;
