Lazy sqr



Lazy sqr
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 >>>>>>>>>}