pragma Extensions_Allowed (On);
--  `'Scan` of a filtered sequence: the running values of the elements kept, one for each
--  (written with a filtered aggregate, so it has no plain Ada form), proved
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   subtype Small is Integer range 0 .. 100;
   type Vector is array (Positive range <>) of Integer;
   type Smalls is array (Positive range <>) of Small;
   function Running_Evens (A : Smalls) return Vector is ([for X of A when X mod 2 = 0 => X]'Scan ("+", 0))
     with Pre => A'Length <= 1_000;
   function Running_Small (N : Small) return Vector is ([for I in 1 .. N when I mod 3 /= 0 => I mod 10]'Scan ("+", 0))
     with Pre => N <= 50;
   procedure Show (V : Vector) is
   begin
      for E of V loop
         Put (Integer'Image (E));
      end loop;
      New_Line;
   end Show;
begin
   Show (Running_Evens ((3, 2, 4, 1, 6)));
   Show (Running_Small (7));
end Main;
