RosettaCodeData/Task/Singly-linked-list-Traversal/Ada/singly-linked-list-traversal.ada
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

18 lines
511 B
Ada

with Ada.Containers.Doubly_Linked_Lists;
with Ada.Text_Io; use Ada.Text_Io;
procedure Traversal_Example is
package Int_List is new Ada.Containers.Doubly_Linked_Lists(Integer);
use Int_List;
procedure Print(Position : Cursor) is
begin
Put_Line(Integer'Image(Element(Position)));
end Print;
The_List : List;
begin
for I in 1..10 loop
The_List.Append(I);
end loop;
-- Traverse the list, calling Print for each value
The_List.Iterate(Print'access);
end traversal_example;