-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathAsymmetric.dpr
More file actions
45 lines (37 loc) · 1.05 KB
/
Asymmetric.dpr
File metadata and controls
45 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
program Asymmetric;
{$APPTYPE CONSOLE}
{$R *.res}
uses
{$I ../Impl.inc}
{$I ../Includes.inc}
System.SysUtils;
(*
Arithmetic progression.
*)
var
A: TAsymmetric<Integer, Integer, Integer, string>;
Func: TAsymmetricRoutine<Integer, Integer, Integer, string>;
begin
Func := function(const Start, Step, Stop: Integer): string
var
Cur, Accum: Integer;
begin
WriteLn(Format('Input parameters: Start = %d; Step = %d; Stop = %d', [Start, Step, Stop]));
Cur := Start;
Accum := Start;
while Cur <= Stop do
begin
WriteLn(Format('Cur = %d', [Cur]));
Yield;
Inc(Cur, Step);
Inc(Accum, Cur)
end;
Result := Format('Result = %d', [Accum]);
end;
A := TAsymmetric<Integer, Integer, Integer, string>.Create(Func, 10, 3, 17);
while IRawGreenlet(A).GetState <> gsTerminated do
IRawGreenlet(A).Switch;
// if you call GetResult before asymmetric is terminated, exception will be raised
WriteLn(Format('A.GetResult = "%s"', [A.GetResult]));
ReadLn;
end.