--  Scans with a filter and in reverse order (B7005-18, -30, D192): a filtered scan's
--  components are the running values at the elements kept; a reverse one's, of as many
--  elements from the last; an aggregate over a constant's bounds has static positions.
pragma Extensions_Allowed (On);
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   subtype Small is Integer range -100 .. 100;
   type Vector is array (1 .. 4) of Integer;
   type Three is array (1 .. 3) of Integer;
   type Values is array (1 .. 4) of Small;
   V : constant Values := (1, -2, 3, 4);
   S : constant Three := [for X of V when X > 0 => X]'Scan ("+", 0);
   R : constant Vector := [for X of reverse V => X]'Scan ("+", 0);
   Q : constant Vector := [for I in reverse 1 .. 4 => I * 10]'Scan ("+", 0);
   Kept : constant Vector := [for I in V'First .. V'Last when V (I) > -5 => I];
begin
   for X of S loop Put (Integer'Image (X)); end loop;
   for X of R loop Put (Integer'Image (X)); end loop;
   for X of Q loop Put (Integer'Image (X)); end loop;
   for X of Kept loop Put (Integer'Image (X)); end loop;
   New_Line;
end Main;
