>>108050308
with Ada.Containers.Indefinite_Vectors;
with Ada.Text_IO;
procedure Trionic is
type Int_Values is array (Positive range <>) of Integer;
function Pedestrian_Is_Trionic (Values : Int_Values) return Boolean is
I : Positive;
Mono_Changed : Boolean;
begin
I := Values'First;
Mono_Changed := False;
loop
exit when Mono_Changed or I = Values'Last;
if Values (I) < Values (I+1) then
I := I + 1;
else
Mono_Changed := True;
end if;
end loop;
if I = Values'Last then
return False;
end if;
Mono_Changed := False;
loop
exit when Mono_Changed or I = Values'Last;
if Values (I) > Values (I+1) then
I := I + 1;
else
Mono_Changed := True;
end if;
end loop;
if I = Values'Last then
return False;
end if;
Mono_Changed := False;
loop
exit when Mono_Changed or I = Values'Last;
if Values (I) < Values (I+1) then
I := I + 1;
else
Mono_Changed := True;
end if;
end loop;
if I = Values'Last then
return True;
else
return False;
end if;
end Pedestrian_Is_Trionic;
package Bool_IO is new Ada.Text_IO.Enumeration_IO (Boolean);
package Case_Vectors is new Ada.Containers.Indefinite_Vectors
(Element_Type => Int_Values,
Index_Type => Positive);
use Case_Vectors;
Cases : Case_Vectors.Vector;
begin
-- positives
Cases.Append ((1,3,5,4,2,6));
Cases.Append ((2,3,4,3,2,3));
-- negatives
Cases.Append ((3,3,5,4,2,6));
Cases.Append ((1,3,5,4,2,2));
Cases.Append ((1,3,5,6,2,1));
for C of Cases loop
Bool_IO.Put (Pedestrian_Is_Trionic (C));
Ada.Text_IO.New_Line;
end loop;
end Trionic;