lambda 表达式

uses System.SysUtils, System.Math;

var
  PowOfTwo: TFunc<IntegerInteger>;
  PowOfThree: TFunc<DoubleDouble>;
begin
  //anonymous method in a variable
  PowOfTwo := function(Degree: Integer): Integer
    begin
      Result := Round(Power(2, Degree));
    end;
  WriteLn('pow8 is 'PowOfTwo(8));
  //pow8 is 256

  PowOfThree := function(Degree: Double): Double
    begin
      Result := Power(3, Degree);
    end;
  WriteLn('pow3 is 'PowOfThree(3):0:1);
  //pow3 is 27.0
end.