Functions as values (no closures yet, and no tests)

This commit is contained in:
Dmitry Boulytchev 2019-09-22 20:15:15 +03:00
parent f5b802ebed
commit d69cb3d49d
12 changed files with 194 additions and 160 deletions

View file

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

View file

@ -1,10 +1,8 @@
global n, k, res;
global n = 2, k = 10;
n := 2;
k := 10;
res := 1;
{local res = 1;
while k > 0 do
res := res * n;
k := k - 1
od;
write(res)
write(res)}

View file

@ -1,11 +1,11 @@
global i, s, j;
global i, s;
i := 0;
s := 0;
while i < 100
do
j := 0;
local j = 0;
while j < 100
do

View file

@ -1,6 +1,4 @@
global n;
n := read ();
global n = read ();
repeat

View file

@ -1,4 +1,4 @@
global n, c, p, cc, q, i, m, d;
global n, c, p, q, i, m, d;
n := read ();
@ -7,7 +7,7 @@ p := 2;
while c do
cc := 1;
local cc = 1;
while cc do
q := 2;
@ -17,8 +17,7 @@ while c do
q := q + 1
od;
if cc then cc := 0 else p := p + 1; cc := 1 fi
if cc then cc := 0 else p := p + 1; cc := 1 fi
od;
d := p;

View file

@ -1,10 +1,12 @@
global i, s, j;
global i, s;
i := 0;
s := 0;
for i := 0, i < 100, i := i+1
do
local j;
for j := 0, j < 100, j := j+1
do
s := s + j

View file

@ -1,12 +1,12 @@
global s, n, p, c, f;
global s, n, p;
s := 0;
n := read ();
p := 2;
while n > 0 do
c := 2;
f := 1;
local c = 2;
local f = 1;
for c := 2, c*c <= p && f, c := c+1
do

View file

@ -33,7 +33,7 @@ infix "+++" at "+" (l1, l2) {
n := read ();
write ({1, 2, 3} === {1, 2, 3});
write ({1, 2, 3} === {1, 2, 3});
write ({1, 2, 3} === {1, 2, 4});
write (1+2 ? {1, 2, 3});
write (1*3+2 ? {1, 2, 3});

View file

@ -25,4 +25,4 @@ i := -1;
while n := s[i := i + 1]; n == 1 !! n == 2 !! n == 3 do
write (n)
od
od