mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Global definitions; regression tests fixed
This commit is contained in:
parent
a3b12425fd
commit
f5b802ebed
56 changed files with 121 additions and 10 deletions
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
z := x*y*3;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
z := y*y;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
write (x-y);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
z := ((x + y) + (x - y)) + ((x - y) - (x + y));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
z := ((x + y) + (x - y)) + ((x - y) - (x / y));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := read ();
|
||||
y := read ();
|
||||
z := x < y;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
x := 1;
|
||||
y := 2;
|
||||
z := x - y - 3;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
global z;
|
||||
|
||||
z := 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9;
|
||||
write (z)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, k, res;
|
||||
|
||||
n := 2;
|
||||
k := 10;
|
||||
res := 1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global i, s, j;
|
||||
|
||||
i := 0;
|
||||
s := 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
x:=0;
|
||||
if x
|
||||
then write(1)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
n := read ();
|
||||
while n >= 0 do
|
||||
if n > 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
n := read ();
|
||||
|
||||
repeat
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
n := read ();
|
||||
|
||||
while n > 0 do
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global s, n;
|
||||
|
||||
n := read ();
|
||||
|
||||
s := 1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, fib_1, fib_2, fib, i;
|
||||
|
||||
n := read ();
|
||||
|
||||
i := 2;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, c, p, cc, q, i, m, d;
|
||||
|
||||
n := read ();
|
||||
|
||||
c := 1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global i, s, j;
|
||||
|
||||
i := 0;
|
||||
s := 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global s, n, p, c, f;
|
||||
|
||||
s := 0;
|
||||
n := read ();
|
||||
p := 2;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, f;
|
||||
|
||||
n := read ();
|
||||
f := 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, fib_1, fib_2, fib, i;
|
||||
|
||||
n := read ();
|
||||
|
||||
fib_1 := 1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global s, n;
|
||||
|
||||
s := 0;
|
||||
|
||||
repeat
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ fun test2 (b) {
|
|||
a := b
|
||||
}
|
||||
|
||||
global x, a, b;
|
||||
|
||||
x := read ();
|
||||
|
||||
test1 ();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, a, b, c;
|
||||
|
||||
fun test1 (a) {
|
||||
write (a)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, a, b, c;
|
||||
|
||||
fun test1 (a) {
|
||||
write (a);
|
||||
print ()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, a, b, c;
|
||||
|
||||
fun print () {
|
||||
write (a);
|
||||
write (b);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, i, result;
|
||||
|
||||
fun fact (n) {
|
||||
if n <= 1
|
||||
then result := 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global i, n, result;
|
||||
|
||||
fun fib (n) {
|
||||
local r;
|
||||
if n <= 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, i;
|
||||
|
||||
fun fib (n) {
|
||||
if n <= 1
|
||||
then return 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, i;
|
||||
|
||||
fun fact (n) {
|
||||
if n <= 1
|
||||
then return 1
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
fun test (n, m) {
|
||||
local i, s;
|
||||
s := 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, x, i;
|
||||
|
||||
fun printString (x) {
|
||||
for i:=0, i<x.length, i:=i+1 do
|
||||
write (x[i])
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, x, i;
|
||||
|
||||
fun printArray (x) {
|
||||
local elem;
|
||||
if x.length == 0 then return fi;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, x, i;
|
||||
|
||||
fun sort (x) {
|
||||
local i, j, y, n;
|
||||
n := x.length;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, x, y;
|
||||
|
||||
fun append (x, y) {
|
||||
case x of
|
||||
Nil -> return y
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, t;
|
||||
|
||||
fun insert (t, x) {
|
||||
case t of
|
||||
Leaf -> return Node (x, Leaf, Leaf)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
fun f (x) {
|
||||
case x of
|
||||
A -> write (1)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
fun f (a) {
|
||||
case a of
|
||||
A (x, y, z) -> write (x + y + z)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, i;
|
||||
|
||||
fun f (x) {
|
||||
case x of
|
||||
Nil -> write (0)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
fun sum (x) {
|
||||
case x of
|
||||
Nil -> return 0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z;
|
||||
|
||||
fun zip (x) {
|
||||
case x of Pair (x, y) ->
|
||||
case x of
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x;
|
||||
|
||||
fun printString (s) {
|
||||
local i;
|
||||
for i := 0, i < s.length, i := i + 1 do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
n := read ();
|
||||
|
||||
case 3 of
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
fun collect_ints_acc (v, tail) {
|
||||
local i;
|
||||
case v of
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, y;
|
||||
|
||||
fun test (n, m) {
|
||||
local i, s;
|
||||
write (n);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, y, y2, t;
|
||||
|
||||
fun test (n, m) {
|
||||
local i, s;
|
||||
s := 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n, x, y;
|
||||
|
||||
n := read ();
|
||||
x := [1];
|
||||
y := [x, x];
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
fun sum (l) {
|
||||
case l of
|
||||
{} -> return 0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
fun hd (l) {
|
||||
case l of
|
||||
h : _ -> return h
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global n;
|
||||
|
||||
infix "===" at "==" (v1, v2) {
|
||||
local s1, s2, i;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
global x, y, z, s, i, n;
|
||||
|
||||
x := y := z := 105;
|
||||
|
||||
n := read ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue