Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b94d47a

Browse files
Add 14 new routines to Maths category
The routines are: * ArraySum overloads * SumOfLogs overloads In both cases overloaded parameters are open arrays of Cardinal, Double, Extended, Int64, Integer, Single & UInt64. Added compile results for all routines for Delphi XE, 11 & 12. Added test info showing advanced / unit tests
1 parent 6c35091 commit b94d47a

File tree

15 files changed

+360
-0
lines changed

15 files changed

+360
-0
lines changed

‎collection/636.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Cardinal): Cardinal; overload;
2+
var
3+
Elem: Cardinal;
4+
begin
5+
Result := 0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/637.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Double): Double; overload;
2+
var
3+
Elem: Double;
4+
begin
5+
Result := 0.0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/638.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Extended): Extended; overload;
2+
var
3+
Elem: Extended;
4+
begin
5+
Result := 0.0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/639.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Int64): Int64; overload;
2+
var
3+
Elem: Int64;
4+
begin
5+
Result := 0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/640.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Integer): Integer; overload;
2+
var
3+
Elem: Integer;
4+
begin
5+
Result := 0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/641.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of Single): Single; overload;
2+
var
3+
Elem: Single;
4+
begin
5+
Result := 0.0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/642.dat‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function ArraySum(const A: array of UInt64): UInt64; overload;
2+
var
3+
Elem: UInt64;
4+
begin
5+
Result := 0;
6+
for Elem in A do
7+
Result := Result + Elem;
8+
end;

‎collection/643.dat‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function SumOfLogs(const A: array of Cardinal): Extended; overload;
2+
{$IFDEF FPC}
3+
const
4+
{$ELSE}
5+
resourcestring
6+
{$ENDIF}
7+
sNotPositive = 'All elements of array A must be > 0';
8+
var
9+
Elem: Cardinal;
10+
begin
11+
Result := 0.0;
12+
for Elem in A do
13+
begin
14+
if Elem = 0 then
15+
raise SysUtils.EArgumentOutOfRangeException(sNotPositive);
16+
Result := Result + System.Ln(Elem);
17+
end;
18+
end;

‎collection/644.dat‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function SumOfLogs(const A: array of Int64): Extended; overload;
2+
{$IFDEF FPC}
3+
const
4+
{$ELSE}
5+
resourcestring
6+
{$ENDIF}
7+
sNotPositive = 'All elements of array A must be > 0';
8+
var
9+
Elem: Int64;
10+
begin
11+
Result := 0.0;
12+
for Elem in A do
13+
begin
14+
if Elem <= 0 then
15+
raise SysUtils.EArgumentOutOfRangeException(sNotPositive);
16+
Result := Result + System.Ln(Elem);
17+
end;
18+
end;

‎collection/645.dat‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function SumOfLogs(const A: array of Integer): Extended; overload;
2+
{$IFDEF FPC}
3+
const
4+
{$ELSE}
5+
resourcestring
6+
{$ENDIF}
7+
sNotPositive = 'All elements of array A must be > 0';
8+
var
9+
Elem: Integer;
10+
begin
11+
Result := 0.0;
12+
for Elem in A do
13+
begin
14+
if Elem <= 0 then
15+
raise SysUtils.EArgumentOutOfRangeException(sNotPositive);
16+
Result := Result + System.Ln(Elem);
17+
end;
18+
end;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /