A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
62
Task/Generator-Exponential/Ada/generator-exponential-3.ada
Normal file
62
Task/Generator-Exponential/Ada/generator-exponential-3.ada
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package body Generator is
|
||||
|
||||
--------------
|
||||
-- Identity --
|
||||
--------------
|
||||
|
||||
function Identity (X : Natural) return Natural is
|
||||
begin
|
||||
return X;
|
||||
end Identity;
|
||||
|
||||
----------
|
||||
-- Skip --
|
||||
----------
|
||||
|
||||
procedure Skip (Gen : access Generator'Class; Count : Positive := 1) is
|
||||
Val : Natural;
|
||||
pragma Unreferenced (Val);
|
||||
begin
|
||||
for I in 1 .. Count loop
|
||||
Val := Gen.Get_Next;
|
||||
end loop;
|
||||
end Skip;
|
||||
|
||||
-----------
|
||||
-- Reset --
|
||||
-----------
|
||||
|
||||
procedure Reset (Gen : in out Generator) is
|
||||
begin
|
||||
Gen.Last_Source := 0;
|
||||
Gen.Last_Value := 0;
|
||||
end Reset;
|
||||
|
||||
--------------
|
||||
-- Get_Next --
|
||||
--------------
|
||||
|
||||
function Get_Next (Gen : access Generator) return Natural is
|
||||
begin
|
||||
Gen.Last_Source := Gen.Last_Source + 1;
|
||||
Gen.Last_Value := Gen.Gen_Func (Gen.Last_Source);
|
||||
return Gen.Last_Value;
|
||||
end Get_Next;
|
||||
|
||||
----------------------------
|
||||
-- Set_Generator_Function --
|
||||
----------------------------
|
||||
|
||||
procedure Set_Generator_Function
|
||||
(Gen : in out Generator;
|
||||
Func : Generator_Function)
|
||||
is
|
||||
begin
|
||||
if Func = null then
|
||||
Gen.Gen_Func := Identity'Access;
|
||||
else
|
||||
Gen.Gen_Func := Func;
|
||||
end if;
|
||||
end Set_Generator_Function;
|
||||
|
||||
end Generator;
|
||||
Loading…
Add table
Add a link
Reference in a new issue