|
with Ada.Text_IO; use Ada.Text_IO; |
|
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; |
|
procedure Foo is |
|
Element_To_Ignore : Integer := 3; |
|
type Array_Of_Integer is array(Positive Range <>) of Integer; |
|
A : Array_Of_Integer := (5,3,2,6); |
|
B : Array_Of_Integer |
|
:= A(A'First .. Element_To_Ignore-1) & |
|
A(Element_To_Ignore+1 .. A'Last); |
|
|
|
procedure Print_Array(Name: String; A: Array_Of_Integer) is |
|
begin |
|
Put(Name); |
|
Put(": ("); |
|
Put(A'First, Width => 0); |
|
Put(".."); |
|
Put(A'Last, Width => 0); |
|
Put(") = ("); |
|
for I in A'Range loop |
|
Put(A(I), Width => 0); |
|
if (I < A'Last) then |
|
Put(", "); |
|
end if; |
|
end loop; |
|
Put_Line(")"); |
|
end Print_Array; |
|
|
|
begin |
|
for Element_To_Ignore in A'First - 3 .. A'Last + 3 loop |
|
Put("Element_To_Ignore = "); Put(Element_To_Ignore, Width => 0); Put(" : "); |
|
begin |
|
declare |
|
B : Array_Of_Integer |
|
:= A(A'First .. Element_To_Ignore-1) & |
|
A(Element_To_Ignore+1 .. A'Last); |
|
begin |
|
Print_Array("B", B); |
|
end; |
|
exception |
|
when Constraint_Error => |
|
Put_Line("Constraint_Error"); |
|
end; |
|
end loop; |
|
end Foo; |