pragma Extensions_Allowed (On);
--  APL's scalar functions of the 1.0 subset (D193): monadic `⌈` `⌊`, `*` `⍟` `○` (e to the
--  power, logarithms, pi times and the circular functions, by Ada.Numerics), the binomial
--  `!`, nand `⍲` and nor `⍱`; proved
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   subtype Small is Integer range -100 .. 100;
   subtype Unit is Long_Float range -1.0 .. 1.0;
   subtype Modest is Long_Float range 0.5 .. 8.0;
   type Smalls is array (Positive range <>) of Small;
   type Units is array (Positive range <>) of Unit;
   type Modests is array (Positive range <>) of Modest;
   type FVector is array (Positive range <>) of Long_Float;
   type Vector is array (Positive range <>) of Integer;
   type BVector is array (Positive range <>) of Boolean;
   X : constant Smalls := (4, 5, 6, 7);
   F : constant Modests := (1.5, 2.5, 4.0, 8.0);
   U : constant Units := (-1.0, -0.5, 0.0, 0.5);
   P : constant BVector := (True, False, True, False);
   Q : constant BVector := (True, True, False, False);
   procedure Show (V : FVector) is
   begin
      for E of V loop
         Put (Long_Float'Image (E));
      end loop;
      New_Line;
   end Show;
   procedure Show (V : Vector) is
   begin
      for E of V loop
         Put (Integer'Image (E));
      end loop;
      New_Line;
   end Show;
   procedure Show (V : BVector) is
   begin
      for E of V loop
         Put (Boolean'Image (E) & " ");
      end loop;
      New_Line;
   end Show;
   Up : constant FVector := APL ("⌈ F");
   Down : constant FVector := APL ("⌊ F");
   Same : constant Vector := APL ("⌈ X");
   Power : constant FVector := APL ("* U");
   Ln : constant FVector := APL ("⍟ F");
   Log2 : constant FVector := APL ("2 ⍟ F");
   Pi_Times : constant FVector := APL ("○ U");
   Sines : constant FVector := APL ("1 ○ U");
   Arcsines : constant FVector := APL ("¯1 ○ U");
   Roots : constant FVector := APL ("0 ○ U");
   Choose : constant Vector := APL ("2 ! X");
   Nand : constant BVector := APL ("P ⍲ Q");
   Nor : constant BVector := APL ("P ⍱ Q");
begin
   Show (Up);
   Show (Down);
   Show (Same);
   Show (Power);
   Show (Ln);
   Show (Log2);
   Show (Pi_Times);
   Show (Sines);
   Show (Arcsines);
   Show (Roots);
   Show (Choose);
   Show (Nand);
   Show (Nor);
end Main;
