forked from pascalabcnet/pascalabcnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
207 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
%COREVERSION%=0 | ||
%REVISION%=1263 | ||
%MINOR%=1 | ||
%REVISION%=1266 | ||
%COREVERSION%=0 | ||
%MAJOR%=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
!define VERSION '3.1.0.1263' | ||
!define VERSION '3.1.0.1266' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function Sq1: sequence of integer; | ||
begin | ||
yield 1; | ||
yield 5; | ||
end; | ||
|
||
function Squares(n: integer): sequence of integer; | ||
begin | ||
for var i:=1 to n do | ||
yield i*i; | ||
yield 666; | ||
begin | ||
yield 777; | ||
end; | ||
end; | ||
|
||
function Sq2(n: integer): sequence of integer; | ||
begin | ||
for var i:=1 to n do | ||
begin | ||
yield i; | ||
yield i; | ||
end; | ||
end; | ||
|
||
|
||
begin | ||
Assert(Sq1.SequenceEqual(Seq(1,5))); | ||
Assert(Squares(5).SequenceEqual(Seq(1,4,9,16,25,666,777)),'not Squares(5).SequenceEqual(Seq(1,4,9,16,25))'); | ||
Assert(Sq2(5).SequenceEqual(Seq(1,1,2,2,3,3,4,4,5,5))); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var z:=1; | ||
|
||
type AAA = class | ||
y: integer := 1; | ||
function f(a: sequence of integer): sequence of integer; | ||
begin | ||
var k: integer = 1; | ||
foreach var x in a do | ||
yield x+y+z+k; | ||
end; | ||
end; | ||
|
||
begin | ||
var a1 := new AAA(); | ||
|
||
var q := a1.f(Range(1,4)); | ||
|
||
var sq := Seq(4,5,6,7); | ||
Assert(q.Println.SequenceEqual(sq)); | ||
Assert(q.Println.SequenceEqual(sq)); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function Sq(n: integer): sequence of integer; | ||
begin | ||
for var i:=1 to n do | ||
case i mod 3 of | ||
0: yield 22; | ||
1: yield 33; | ||
2: yield 44; | ||
end; | ||
yield 55; | ||
end; | ||
|
||
procedure AssertSeq<T>(q,correct: sequence of T); | ||
begin | ||
Assert(q.SequenceEqual(correct),q.JoinIntoString); | ||
end; | ||
|
||
|
||
begin | ||
AssertSeq(Sq(5).Println,Seq(33,44,22,33,44,55)); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function f(n: integer): sequence of integer; | ||
begin | ||
var m := n; | ||
case m of | ||
1: begin | ||
yield 3; | ||
for var i:=1 to 5 do | ||
yield i; | ||
end; | ||
2: for var i:=1 to 5 do | ||
case i of | ||
1,2,3: yield 4; | ||
4..20: yield -1 | ||
end; | ||
else yield 5; | ||
end; | ||
end; | ||
|
||
procedure AssertSeq<T>(q,correct: sequence of T); | ||
begin | ||
Assert(q.SequenceEqual(correct),q.JoinIntoString); | ||
end; | ||
|
||
begin | ||
AssertSeq(f(1).Println,Seq(3,1,2,3,4,5)); | ||
AssertSeq(f(2).Println,Seq(4,4,4,-1,-1)); | ||
AssertSeq(f(3).Println,Seq(5)); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function Sq1: sequence of integer; | ||
begin | ||
yield 1; | ||
yield 5; | ||
end; | ||
|
||
function Squares(n: integer): sequence of integer; | ||
begin | ||
for var i:=1 to n do | ||
yield i*i; | ||
yield 666; | ||
begin | ||
yield 777; | ||
end; | ||
end; | ||
|
||
function Sq2(n: integer): sequence of integer; | ||
begin | ||
yield(555); | ||
for var i:=1 to n do | ||
begin | ||
yield i; | ||
yield i; | ||
end; | ||
end; | ||
|
||
|
||
begin | ||
Assert(Sq1.SequenceEqual(Seq(1,5)),'1'); | ||
Assert(Squares(5).SequenceEqual(Seq(1,4,9,16,25,666,777)),'not Squares(5).SequenceEqual(Seq(1,4,9,16,25))'); | ||
Assert(Sq2(5).SequenceEqual(Seq(555,1,1,2,2,3,3,4,4,5,5)),'3'); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function Sq(n: integer): sequence of integer; | ||
begin | ||
for var i:=1 to n do | ||
for var j:=1 to n do | ||
begin | ||
yield i*j; | ||
end; | ||
end; | ||
|
||
|
||
begin | ||
Assert(Sq(3).SequenceEqual(Seq(1,2,3,2,4,6,3,6,9)),Sq(3).JoinIntoString); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function Sq(n: integer): sequence of integer; | ||
begin | ||
if n mod 2 = 0 then | ||
yield 555 | ||
else yield 444; | ||
end; | ||
|
||
function Where1<T>(s: sequence of T; p: T->boolean): sequence of T; | ||
begin | ||
foreach var x in s do | ||
//if p(x) then | ||
yield x; | ||
end; | ||
|
||
begin | ||
Assert(Sq(2).SequenceEqual(Seq(555)),Sq(2).JoinIntoString); | ||
Assert(Sq(1).SequenceEqual(Seq(444)),Sq(2).JoinIntoString); | ||
var q := Where1(Arr(1,2,3,4),x->x mod 2 <>0); | ||
q.Println; | ||
//q.Println; | ||
//Assert(q.SequenceEqual(Seq(444)),q.JoinIntoString); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function f<T>(a: sequence of T): sequence of T; | ||
begin | ||
foreach var x in a do | ||
yield x; | ||
end; | ||
|
||
begin | ||
var q := f(Range(1,4)); | ||
|
||
var sq := Seq(1,2,3,4); | ||
Assert(q.Println.SequenceEqual(sq)); | ||
Assert(q.Println.SequenceEqual(sq)); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function Sq(n: integer): sequence of integer; | ||
begin | ||
var i:=1; | ||
while i<=n do | ||
begin | ||
yield i; | ||
i += 1; | ||
end; | ||
repeat | ||
yield i; | ||
i -= 1; | ||
until i<=0; | ||
end; | ||
|
||
|
||
begin | ||
Assert(Sq(3).SequenceEqual(Seq(1,2,3,4,3,2,1)),Sq(3).JoinIntoString); | ||
end. |
Binary file not shown.