File tree Expand file tree Collapse file tree 17 files changed +853
-0
lines changed Expand file tree Collapse file tree 17 files changed +853
-0
lines changed Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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;
You can’t perform that action at this time.
0 commit comments