pragma Extensions_Allowed (On);
--  APL text (T32b): scalar functions, ⍳, ≢, ⌽, ↑, catenation, reductions along an axis
--  and a dfn, lowered to pipelines and aggregates, 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;
   X : constant Smalls := (1, 2, 3, 4);
   Y : constant Smalls := (10, 20, 30, 40);
   A : constant Matrix := ((1, 2), (3, 4));
   B : constant Matrix := ((5, 6), (7, 8));
   procedure Show (V : Vector) is
   begin
      for E of V loop
         Put (Integer'Image (E));
      end loop;
      New_Line;
   end Show;
   Dot : constant Integer := APL ("+/ X × Y");
   Squares : constant Vector := APL ("(⍳ 5) × ⍳ 5");
   Rev : constant Vector := APL ("⌽ X");
   Joined : constant Vector := APL ("X , 2 ↑ Y");
   Mean_Ish : constant Integer := APL ("(+/ X) - ≢ X");
   Rows : constant Vector := APL ("+/ A");
   Twice : constant Vector := APL ("{⍵ + ⍵} X");
begin
   Put_Line (Integer'Image (Dot) & Integer'Image (Mean_Ish));
   Show (Squares);
   Show (Rev);
   Show (Joined);
   Show (Rows);
   Show (Twice);
end Main;
