pragma Extensions_Allowed (On);
--  APL text (T32b): `⌈/` and `⌊/` (of the host array's component type), `-/` right to left,
--  scans, take and drop from the end, and compress, 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 := (3, 1, 4, 1, 5);
   A : constant Matrix := ((1, 7), (9, 2));
   procedure Show (V : Vector) is
   begin
      for E of V loop
         Put (Integer'Image (E));
      end loop;
      New_Line;
   end Show;
   Largest : constant Integer := APL ("⌈/ X");
   Least : constant Integer := APL ("⌊/ X");
   Alternating : constant Integer := APL ("-/ X");
   Row_Max : constant Vector := APL ("⌈/ A");
   Column_Min : constant Vector := APL ("⌊⌿ A");
   Running : constant Vector := APL ("+\ X");
   Peaks : constant Vector := APL ("⌈\ X");
   Last_Two : constant Vector := APL ("¯2 ↑ X");
   Padded : constant Vector := APL ("¯7 ↑ X");
   But_Last : constant Vector := APL ("¯2 ↓ X");
   Big : constant Vector := APL ("(X > 2) / X");
   Picked : constant Vector := APL ("1 0 1 0 1 / X");
   Big_Sum : constant Integer := APL ("+/ (X > 2) / X");
   Big_Alternating : constant Integer := APL ("-/ (X > 1) / X");
begin
   Put_Line (Integer'Image (Largest) & Integer'Image (Least) & Integer'Image (Alternating));
   Show (Row_Max);
   Show (Column_Min);
   Show (Running);
   Show (Peaks);
   Show (Last_Two);
   Show (Padded);
   Show (But_Last);
   Show (Big);
   Show (Picked);
   Put_Line (Integer'Image (Big_Sum));
   Put_Line (Integer'Image (Big_Alternating));
end Main;
