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 a437d10

Browse files
Merge branch 'feature/25-add-summing-routines' into develop
Fixes #25
2 parents 8212ad2 + b94d47a commit a437d10

File tree

17 files changed

+853
-0
lines changed

17 files changed

+853
-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 によって変換されたページ (->オリジナル) /