Logo

Programming-Idioms

History of Idiom 7 > diff from v44 to v45

Edit summary for version 45 by :
[Ada] Use variable 'x'

Version 44

2016-02-16, 15:24:07

Version 45

2016-02-16, 16:46:54

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Imports
with Ada.Text_IO;
use Ada.Text_IO;
Imports
with Ada.Text_IO;
use Ada.Text_IO;
Code
for I in Items'Range loop
   Put_Line (Integer'Image (I) & " " & Integer'Image (Items (I)));
end loop;
Code
for I in Items'Range loop
   X := Items (I);
   Put_Line (Integer'Image (I) & " " & Integer'Image (X));
end loop;
Comments bubble
Assuming Items is an array of integers.
Comments bubble
Assuming Items is an array of integers.