Global definitions; regression tests fixed

This commit is contained in:
Dmitry Boulytchev 2019-09-19 18:37:08 +03:00
parent a3b12425fd
commit f5b802ebed
56 changed files with 121 additions and 10 deletions

View file

@ -1,3 +1,5 @@
global x, y, z;
x := read ();
y := read ();
z := x*y*3;

View file

@ -1,3 +1,5 @@
global x, y, z;
x := read ();
y := read ();
z := y*y;

View file

@ -1,3 +1,5 @@
global x, y;
x := read ();
y := read ();
write (x-y);

View file

@ -1,3 +1,5 @@
global x, y, z;
x := read ();
y := read ();
z := ((x + y) + (x - y)) + ((x - y) - (x + y));

View file

@ -1,3 +1,5 @@
global x, y, z;
x := read ();
y := read ();
z := ((x + y) + (x - y)) + ((x - y) - (x / y));

View file

@ -1,3 +1,5 @@
global x, y, z;
x := read ();
y := read ();
z := x < y;

View file

@ -1,3 +1,5 @@
global x, y, z;
x := 1;
y := 2;
z := x - y - 3;

View file

@ -1,2 +1,4 @@
global z;
z := 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9;
write (z)

View file

@ -1,3 +1,5 @@
global n, k, res;
n := 2;
k := 10;
res := 1;

View file

@ -1,3 +1,5 @@
global i, s, j;
i := 0;
s := 0;

View file

@ -1,3 +1,5 @@
global x;
x:=0;
if x
then write(1)

View file

@ -1,3 +1,5 @@
global n;
n := read ();
while n >= 0 do
if n > 1

View file

@ -1,3 +1,5 @@
global n;
n := read ();
repeat

View file

@ -1,3 +1,5 @@
global n;
n := read ();
while n > 0 do

View file

@ -1,10 +1,11 @@
global s, n, p;
s := 0;
n := read ();
p := 2;
while n > 0 do
c := 2;
f := 1;
while n > 0 do {
local c = 2, f = 1;
while c*c <= p && f do
f := (p % c) != 0;
@ -17,4 +18,5 @@ while n > 0 do
else skip fi;
p := p + 1
}
od

View file

@ -1,3 +1,5 @@
global s, n;
n := read ();
s := 1;

View file

@ -1,3 +1,5 @@
global n, fib_1, fib_2, fib, i;
n := read ();
i := 2;

View file

@ -1,3 +1,5 @@
global n, c, p, cc, q, i, m, d;
n := read ();
c := 1;

View file

@ -1,3 +1,5 @@
global i, s, j;
i := 0;
s := 0;

View file

@ -1,3 +1,5 @@
global s, n, p, c, f;
s := 0;
n := read ();
p := 2;

View file

@ -1,3 +1,5 @@
global n, f;
n := read ();
f := 1;

View file

@ -1,3 +1,5 @@
global n, fib_1, fib_2, fib, i;
n := read ();
fib_1 := 1;

View file

@ -1,3 +1,5 @@
global s, n;
s := 0;
repeat

View file

@ -6,6 +6,8 @@ fun test2 (b) {
a := b
}
global x, a, b;
x := read ();
test1 ();

View file

@ -1,3 +1,5 @@
global x, a, b, c;
fun test1 (a) {
write (a)
}

View file

@ -1,3 +1,5 @@
global x, a, b, c;
fun test1 (a) {
write (a);
print ()

View file

@ -1,3 +1,5 @@
global x, a, b, c;
fun print () {
write (a);
write (b);

View file

@ -1,3 +1,5 @@
global n, i, result;
fun fact (n) {
if n <= 1
then result := 1

View file

@ -1,3 +1,5 @@
global i, n, result;
fun fib (n) {
local r;
if n <= 1

View file

@ -1,3 +1,5 @@
global n, i;
fun fib (n) {
if n <= 1
then return 1

View file

@ -1,3 +1,5 @@
global n, i;
fun fact (n) {
if n <= 1
then return 1

View file

@ -1,3 +1,5 @@
global x, m, n;
fun ack (m, n) {
if m == 0 then return (n+1)
elif m > 0 && n == 0 then return ack (m-1, 1)

View file

@ -1,3 +1,5 @@
global x;
fun test (n, m) {
local i, s;
s := 0;

View file

@ -1,3 +1,5 @@
global n, x, i;
fun printString (x) {
for i:=0, i<x.length, i:=i+1 do
write (x[i])

View file

@ -1,3 +1,5 @@
global n, x, i;
fun printArray (x) {
local elem;
if x.length == 0 then return fi;

View file

@ -1,3 +1,5 @@
global x, y, i, j;
fun printAS (x) {
local i, j;
for i := 0, i<x.length, i:=i+1 do

View file

@ -1,3 +1,5 @@
global n, x, i;
fun sort (x) {
local i, j, y, n;
n := x.length;

View file

@ -1,3 +1,5 @@
global n, x, y;
fun append (x, y) {
case x of
Nil -> return y

View file

@ -1,3 +1,5 @@
global n, t;
fun insert (t, x) {
case t of
Leaf -> return Node (x, Leaf, Leaf)

View file

@ -1,3 +1,5 @@
global x;
fun f (x) {
case x of
A -> write (1)

View file

@ -1,3 +1,5 @@
global x;
fun f (a) {
case a of
A (x, y, z) -> write (x + y + z)

View file

@ -1,3 +1,5 @@
global x, y, i;
fun f (x) {
case x of
Nil -> write (0)

View file

@ -1,3 +1,5 @@
global x;
fun sum (x) {
case x of
Nil -> return 0

View file

@ -1,3 +1,5 @@
global x, y, z;
fun zip (x) {
case x of Pair (x, y) ->
case x of

View file

@ -1,3 +1,5 @@
global x;
fun printString (s) {
local i;
for i := 0, i < s.length, i := i + 1 do

View file

@ -1,3 +1,5 @@
global n;
n := read ();
case 3 of

View file

@ -1,3 +1,5 @@
global n;
fun collect_ints_acc (v, tail) {
local i;
case v of

View file

@ -1,3 +1,5 @@
global n, y;
fun test (n, m) {
local i, s;
write (n);

View file

@ -1,3 +1,5 @@
global n, y, y2, t;
fun test (n, m) {
local i, s;
s := 0;

View file

@ -1,3 +1,5 @@
global n, x, y;
n := read ();
x := [1];
y := [x, x];

View file

@ -1,3 +1,5 @@
global n;
fun sum (l) {
case l of
{} -> return 0

View file

@ -1,3 +1,5 @@
global n;
fun hd (l) {
case l of
h : _ -> return h

View file

@ -1,3 +1,5 @@
global n;
infix "===" at "==" (v1, v2) {
local s1, s2, i;

View file

@ -1,3 +1,5 @@
global x, y, z, s, i, n;
x := y := z := 105;
n := read ();