* Patch from Thaddy De Koning to add generic RandomFrom

git-svn-id: trunk@36706 -
This commit is contained in:
michael 2017-07-09 10:11:01 +00:00
parent 03267e3ba3
commit 162b938409

View File

@ -613,8 +613,12 @@ function CompareValue ( const A, B : Extended; delta : Extended = 0.0 ) : TValue
function RandomFrom(const AValues: array of Double): Double; overload;
function RandomFrom(const AValues: array of Integer): Integer; overload;
function RandomFrom(const AValues: array of Int64): Int64; overload;
{$if FPC_FULLVERSION >=301010}
generic function RandomFrom<T>(const AValues:array of T):T;
{$endif}
{ cpu specific stuff }
type
TFPURoundingMode = system.TFPURoundingMode;
TFPUPrecisionMode = system.TFPUPrecisionMode;
@ -2600,6 +2604,13 @@ begin
result:=AValues[random(High(AValues)+1)];
end;
{$if FPC_FULLVERSION >=301010}
generic function RandomFrom<T>(const AValues:array of T):T;
begin
result:=AValues[random(High(AValues)+1)];
end;
{$endif}
function FutureValue(ARate: Float; NPeriods: Integer;
APayment, APresentValue: Float; APaymentTime: TPaymentTime): Float;
var