aboutsummaryrefslogtreecommitdiff
path: root/challenge-171/deadmarshal/pascal/ch2.pas
blob: e83fe6fca9fb0b651caedeb1ea85023bf9b7cbfe (plain)
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
program Ch2;

{$mode objfpc}
uses
   SysUtils,Classes;
type
   TFunction = function(N:Integer):Integer;
   
function F(N:Integer):Integer;
begin F := N + 2; end;

function G(N:Integer):Integer;
begin G := N * 2; end;

function Res(N:Integer):Integer;
begin Res := F(G(N)); end;

function Compose(F,G:TFunction):TFunction;
begin
   Result := @Res;
end;

begin
   WriteLn(Compose(@F, @G)(5));
end.