Smart pascal source code
var k: Integer = 1;
var f: Float := 2;
function GlobInc: Integer;
begin
Result := Inc(k, 1);
end;
function GlobFloat: Float;
begin
Result := f;
f + = 2;
end;
procedure TestInt(lazy i: Integer);
begin
WriteLn(Sqr(i));
WriteLn(Sqr(i));
WriteLn(i * i);
WriteLn(i * i);
end;
procedure TestFloat(lazy v: Float);
begin
WriteLn(Sqr(v));
WriteLn(Sqr(v));
WriteLn(v * v);
WriteLn(v * v);
end;
TestInt(GlobInc);
TestFloat(GlobFloat);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
4
9
20
42
4
16
48
120
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var k = 0,
f = 0;
function TestFloat(v) {
WriteLn((Math.pow(v(),2)));
WriteLn((Math.pow(v(),2)));
WriteLn((v()*v()));
WriteLn((v()*v()));
};
function TestInt(i) {
WriteLn((Math.pow(i(),2)));
WriteLn((Math.pow(i(),2)));
WriteLn((i()*i()));
WriteLn((i()*i()));
};
function GlobFloat() {
var Result = 0;
Result = f;
f+=2;
return Result
};
function GlobInc() {
var Result = 0;
Result = ++k;
return Result
};
k = 1;
f = 2;
TestInt(function () { return GlobInc()});
TestFloat(function () { return GlobFloat()});