Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
package Synchronous_Concurrent is
task Printer is
entry Put(Item : in String);
entry Get_Count(Count : out Natural);
end Printer;
end Synchronous_Concurrent;

View file

@ -0,0 +1,26 @@
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Synchronous_Concurrent is
task body Printer is
Num_Iter : Natural := 0;
Line : Unbounded_String;
begin
loop
select
accept Put(Item : in String) do
Line := To_Unbounded_String(Item);
end Put;
Put_Line(To_String(Line));
Num_Iter := Num_Iter + 1;
or
accept Get_Count(Count : out Natural) do
Count := Num_Iter;
end Get_Count;
or terminate;
end select;
end loop;
end Printer;
end Synchronous_Concurrent;

View file

@ -0,0 +1,19 @@
with Synchronous_Concurrent; use Synchronous_Concurrent;
with Ada.Text_Io; use Ada.Text_Io;
procedure Synchronous_Concurrent_Main is
Num_Strings : Natural;
The_File : File_Type;
Line : String(1..255);
Length : Natural;
begin
Open(File => The_File, Mode => In_File, Name => "input.txt");
while not End_Of_File(The_File) loop
Get_Line(File => The_File, Item => Line, Last => Length);
Printer.Put(Line(1..Length));
end loop;
Close(The_File);
Printer.Get_Count(Num_Strings);
New_Line;
Put_Line("The task wrote" & Natural'Image(Num_Strings) & " strings.");
end Synchronous_Concurrent_Main;