Skip to content

Commit 6ea6d05

Browse files
committed
branding and Delphi compatibility
1 parent 847a49f commit 6ea6d05

7 files changed

Lines changed: 316 additions & 94 deletions

File tree

examples/pascal/Max_array.pas

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/pascal/Sum_over_array.pas

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
unit output;
2-
3-
interface
4-
5-
function SumOverArray(const Input: array of Integer): Integer;
6-
7-
implementation
1+
program Sum_over_array;
82

93
function SumOverArray(const Input: array of Integer): Integer;
104
var
11-
I: Integer;
5+
I: Integer;
126
begin
13-
SumOverArray := 0;
7+
SumOverArray := 0;
148

15-
for I := Low(Input) to High(Input) do
16-
begin
17-
SumOverArray += Input[I];
18-
end;
9+
for I := Low(Input) to High(Input) do
10+
begin
11+
inc(Result, Input[I]);
12+
end;
1913
end;
2014

15+
begin
16+
Writeln(SumOverArray([1,2,3,4,5,6,7,8,9,10]));
2117
end.

examples/pascal/default.pas

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
unit output;
2-
3-
interface
4-
5-
function Square(const num: Integer): Integer;
6-
7-
implementation
8-
9-
// Type your code here, or load an example.
1+
program dafult;
102

113
function Square(const num: Integer): Integer;
124
begin
135
Square := num * num;
146
end;
157

8+
begin
9+
Writeln('Hello world');
10+
Writeln(Square(2));
1611
end.

examples/pascal/multiples35.pas

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
program multiples35;
2+
3+
uses
4+
System.SysUtils;
5+
6+
var
7+
Cnt: Integer;
8+
Idx: Integer;
9+
Total: Integer;
10+
begin
11+
// If we list all the natural numbers
12+
// below 10 that are multiples of 3 or 5,
13+
// we get 3,5,6 and 9.
14+
// The sum of these multiples is 23.
15+
//
16+
// Find the sum of all the multiples of 3 or 5 below 1000.
17+
try
18+
Total := 0;
19+
Cnt := 0;
20+
Write('Multiples: 3');
21+
22+
for Idx := 4 to 9999 do begin
23+
if (Idx mod 15 = 0) or
24+
(Idx mod 3 = 0) or
25+
(Idx mod 5 = 0) then
26+
begin
27+
Inc(Cnt);
28+
Total := Total + Idx;
29+
Write(', ', Idx);
30+
end;
31+
end;
32+
33+
Writeln;
34+
Writeln('Totaling ',
35+
FormatFloat('#,###', Total), ' over ',
36+
FormatFloat('#,###', Cnt), ' multiples.');
37+
except
38+
on E: Exception do begin
39+
Writeln(E.ClassName, ': ', E.Message);
40+
end;
41+
end;
42+
end.

public/site-logo(original).svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)