text
stringlengths
0
234
end loop;
Ada.Text_IO.Put (Stemmer.Factory.Stem (Lang, Line (Start_Pos .. Pos - 1)));
end loop;
Ada.Text_IO.New_Line;
Function Definition: procedure Stemargs is
Function Body: use Stemmer.Factory;
function Get_Language (Name : in String) return Language_Type;
function Get_Language (Name : in String) return Language_Type is
begin
return Language_Type'Value ("L_" & Name);
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line ("Unsupported language: " & Ada.Command_Line.Argument (1));
return L_ENGLISH;
end Get_Language;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: stemargs language words...");
return;
end if;
declare
Lang : constant Language_Type := Get_Language (Ada.Command_Line.Argument (1));
begin
for I in 2 .. Count loop
Ada.Text_IO.Put_Line (Stem (Lang, Ada.Command_Line.Argument (I)));
end loop;
Function Definition: procedure Car is
Function Body: --class
type Car is tagged
record
wheels : Integer;
doors : Integer;
cylinders : Integer;
end record;
-- functions
--prior to Ada 2012, passed arguments could not be written to
--that would defeat the purpose of writing functions for records
procedure addWheels(myCar : in out Car; wheelsIn : Integer)
is
begin
myCar.wheels := myCar.wheels + wheelsIn;
end addWheels;
procedure addDoors(myCar : in out Car; doorsIn : Integer)
is
begin
myCar.doors := myCar.doors + doorsIn;
end addDoors;
procedure addCylinders(myCar : in out Car; cylindersIn : Integer)
is
begin
myCar.cylinders := myCar.cylinders + cylindersIn;
end addCylinders;
procedure deleteWheels(myCar : in out Car; wheelsIn : Integer)
is
begin
myCar.wheels := myCar.wheels - wheelsIn;
end deleteWheels;
procedure deleteDoors(myCar : in out Car; doorsIn : Integer)
is
begin
myCar.doors := myCar.doors - doorsIn;
end deleteDoors;
procedure deleteCylinders(myCar : in out Car; cylindersIn : Integer)
is
begin
myCar.cylinders := myCar.cylinders - cylindersIn;
end deleteCylinders;
--main program block
begin
Put_Line("Creating car.");
declare
subaru : Car;
begin
subaru.wheels := 4;
subaru.doors := 4;
subaru.cylinders := 4;
Put("Wheel check: ");
Put(Integer'Image(subaru.wheels));
New_Line;
Put("Door check: ");
Put(Integer'Image(subaru.doors));
New_Line;
Put("Cylinder check: ");
Put(Integer'Image(subaru.cylinders));
New_Line;
New_Line;