| 1 |
-- { dg-do run } |
| 2 |
-- { dg-output "1 2 3 4 5 6 7 \| 1- 1 2 3 2- 1 2 3 3- 1 2 3 4- 1 2 3 5- 1 2 3" } |
| 3 |
|
| 4 |
with Ada.Text_IO; use Ada.Text_IO; |
| 5 |
|
| 6 |
procedure Exit1 is |
| 7 |
type Int_Range is record |
| 8 |
First, Last : Integer; |
| 9 |
end record |
| 10 |
with Iterable => (First => First, |
| 11 |
Next => Next, |
| 12 |
Previous => Previous, |
| 13 |
Last => Last, |
| 14 |
Has_Element => Has_Element, |
| 15 |
Element => Element); |
| 16 |
|
| 17 |
function First (IR : Int_Range) return Integer is (IR.First); |
| 18 |
function Last (IR : Int_Range) return Integer is (IR.Last); |
| 19 |
function Next (IR : Int_Range; N : Integer) return Integer is (N + 1); |
| 20 |
function Previous (IR : Int_Range; N : Integer) return Integer is (N - 1); |
| 21 |
function Has_Element (IR : Int_Range; N : Integer) return Boolean is |
| 22 |
(N in IR.First ..IR.Last); |
| 23 |
function Element (IR : Int_Range; N : Integer) return Integer is (N); |
| 24 |
|
| 25 |
IR : Int_Range := (1, 10); |
| 26 |
|
| 27 |
begin |
| 28 |
A_Loop: for I of IR loop |
| 29 |
Put (I'Img); |
| 30 |
exit A_Loop when I = 7; |
| 31 |
end loop A_Loop; |
| 32 |
Put (" | "); |
| 33 |
|
| 34 |
B_Loop: for I of IR loop |
| 35 |
Put (I'Img & '-'); |
| 36 |
C_Loop : for J of IR loop |
| 37 |
Put (J'Img); |
| 38 |
exit when J = 3; |
| 39 |
end loop C_Loop; |
| 40 |
|
| 41 |
exit B_Loop when I = 5; |
| 42 |
end loop B_Loop; |
| 43 |
New_Line; |
| 44 |
|
| 45 |
end Exit1; |