Init next project
This commit is contained in:
2
Project-02/triplaprograms/argsParamsExample.tripla
Normal file
2
Project-02/triplaprograms/argsParamsExample.tripla
Normal file
@@ -0,0 +1,2 @@
|
||||
let a(x,y,z) {x}
|
||||
in a(1,2,3)
|
||||
15
Project-02/triplaprograms/complex.tripla
Normal file
15
Project-02/triplaprograms/complex.tripla
Normal file
@@ -0,0 +1,15 @@
|
||||
let
|
||||
f1(b) {
|
||||
if(b==0) then 0 else f1(b-1)
|
||||
}
|
||||
f2(a, b) {
|
||||
if(a > b) then f1(a) else f1(b);
|
||||
let g(c) {
|
||||
a*b*c
|
||||
} in g(a*b)
|
||||
}
|
||||
in
|
||||
f1(10); f2(10, let max(a, b) {
|
||||
if(a > b) then a else b
|
||||
}
|
||||
in max(20, 30))
|
||||
1
Project-02/triplaprograms/condition.tripla
Normal file
1
Project-02/triplaprograms/condition.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if 2 < x && x > 9 then 1 else 0
|
||||
4
Project-02/triplaprograms/defSemiExample.tripla
Normal file
4
Project-02/triplaprograms/defSemiExample.tripla
Normal file
@@ -0,0 +1,4 @@
|
||||
let a(x) {x}
|
||||
b(y) {y}
|
||||
c(z) {z}
|
||||
in a(1); b(2); c(3)
|
||||
38
Project-02/triplaprograms/factorial.tripla
Normal file
38
Project-02/triplaprograms/factorial.tripla
Normal file
@@ -0,0 +1,38 @@
|
||||
let
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
fac(x) {
|
||||
if (x == 1) then 1
|
||||
else fac(x-1)*x
|
||||
}
|
||||
in fac(3)
|
||||
1
Project-02/triplaprograms/faulty-multiple-let.tripla
Normal file
1
Project-02/triplaprograms/faulty-multiple-let.tripla
Normal file
@@ -0,0 +1 @@
|
||||
let n(a) {a} in n(5) + m(5) ; let m(a) {a+1} in m(5)
|
||||
1
Project-02/triplaprograms/faulty_if.tripla
Normal file
1
Project-02/triplaprograms/faulty_if.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (2 && 7 > 2) then 1 else 0
|
||||
7
Project-02/triplaprograms/func.tripla
Normal file
7
Project-02/triplaprograms/func.tripla
Normal file
@@ -0,0 +1,7 @@
|
||||
let func(a,b) {
|
||||
do {
|
||||
b = b + 1;
|
||||
a = a - 1
|
||||
} while ( a > 0 && b != a )
|
||||
}
|
||||
in func(10, 8)
|
||||
12
Project-02/triplaprograms/ggT_euclid_iter.tripla
Normal file
12
Project-02/triplaprograms/ggT_euclid_iter.tripla
Normal file
@@ -0,0 +1,12 @@
|
||||
let ggT(a, b) {
|
||||
if (a == b) then
|
||||
a
|
||||
else
|
||||
do {
|
||||
if (a > b) then
|
||||
a = a - b
|
||||
else
|
||||
b = b - a
|
||||
} while (a != b);
|
||||
a
|
||||
} in ggT(3528, 3780) // result should be 252
|
||||
8
Project-02/triplaprograms/ggT_euclid_rec.tripla
Normal file
8
Project-02/triplaprograms/ggT_euclid_rec.tripla
Normal file
@@ -0,0 +1,8 @@
|
||||
let ggT(a, b) {
|
||||
if (a == b) then
|
||||
a
|
||||
else if (a > b) then
|
||||
ggT(a-b, b)
|
||||
else
|
||||
ggT(b-a, a)
|
||||
} in ggT(3528, 3780) // result should be 252
|
||||
3
Project-02/triplaprograms/invalidProgram.tripla
Normal file
3
Project-02/triplaprograms/invalidProgram.tripla
Normal file
@@ -0,0 +1,3 @@
|
||||
let f1(b) { if (b == 0) then 0 else f1(b-1) }
|
||||
f2(a,b) { if (a > b) then f1(a) else f1(b) }
|
||||
in f1(10); f2(10,-20)
|
||||
@@ -0,0 +1 @@
|
||||
let m(a){a} in m(5);let m(b){b+1} in m(5)
|
||||
1
Project-02/triplaprograms/multiple-let.tripla
Normal file
1
Project-02/triplaprograms/multiple-let.tripla
Normal file
@@ -0,0 +1 @@
|
||||
let n(a) {a} in n(5) ; let m(a) {a+1} in n(5) + m(5)
|
||||
1
Project-02/triplaprograms/or.tripla
Normal file
1
Project-02/triplaprograms/or.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if(true||true==true) then 1 else 0
|
||||
3
Project-02/triplaprograms/p1.tripla
Normal file
3
Project-02/triplaprograms/p1.tripla
Normal file
@@ -0,0 +1,3 @@
|
||||
let g(a) {
|
||||
a*a
|
||||
} in g(5)
|
||||
9
Project-02/triplaprograms/p2.tripla
Normal file
9
Project-02/triplaprograms/p2.tripla
Normal file
@@ -0,0 +1,9 @@
|
||||
let f1(b) {
|
||||
if (b==0) then 0 else f1(b-1)
|
||||
} in f1(10)
|
||||
/*
|
||||
f2(a,b) {
|
||||
if (a>b) then f1(a) else f1(b)
|
||||
}
|
||||
in f1(10); f2(10,20)
|
||||
*/
|
||||
14
Project-02/triplaprograms/p3.tripla
Normal file
14
Project-02/triplaprograms/p3.tripla
Normal file
@@ -0,0 +1,14 @@
|
||||
let f1(b) {
|
||||
if (b==0) then 0 else f1(b-1)
|
||||
}
|
||||
f2(a,b) {
|
||||
if (a>b) then f1(a) else f1(b);
|
||||
let g(c) {
|
||||
a*b*c
|
||||
}
|
||||
in g(a*b)
|
||||
}
|
||||
in f1(10); f2(10, let max(a,b) {
|
||||
if (a>b) then a else b
|
||||
}
|
||||
in max(20,30) )
|
||||
4
Project-02/triplaprograms/p4.tripla
Normal file
4
Project-02/triplaprograms/p4.tripla
Normal file
@@ -0,0 +1,4 @@
|
||||
let func(a,b) {
|
||||
a = b + 1
|
||||
}
|
||||
in func(10, 8)
|
||||
9
Project-02/triplaprograms/p5.tripla
Normal file
9
Project-02/triplaprograms/p5.tripla
Normal file
@@ -0,0 +1,9 @@
|
||||
let func(a, b) {
|
||||
let func(a, b) {
|
||||
a * b
|
||||
} in
|
||||
do {
|
||||
b = b + 1 * func(3, 1);
|
||||
a = a - 1
|
||||
} while ( a > 0 && b != a )
|
||||
} in func(10, 8)
|
||||
13
Project-02/triplaprograms/p6.tripla
Normal file
13
Project-02/triplaprograms/p6.tripla
Normal file
@@ -0,0 +1,13 @@
|
||||
let f(a, b) {
|
||||
if (a == 0) then
|
||||
2 + b
|
||||
else
|
||||
let g(a, c) {
|
||||
a + c + b
|
||||
} in 2 + g(a, b)
|
||||
} g(c, d) {
|
||||
if (c == 0) then
|
||||
1 + d
|
||||
else
|
||||
c * f(c - 1, d)
|
||||
} in f (2, 3); g (3, 2)
|
||||
5
Project-02/triplaprograms/side_effect.tripla
Normal file
5
Project-02/triplaprograms/side_effect.tripla
Normal file
@@ -0,0 +1,5 @@
|
||||
let f(x, y) {
|
||||
let g(x) {
|
||||
y = x + 7
|
||||
} in x = g(5); y
|
||||
} in f(1, 2)
|
||||
4
Project-02/triplaprograms/simple_dfa.tripla
Normal file
4
Project-02/triplaprograms/simple_dfa.tripla
Normal file
@@ -0,0 +1,4 @@
|
||||
let g(x, y) {
|
||||
y = 3;
|
||||
x
|
||||
} in g(2)
|
||||
1
Project-02/triplaprograms/simple_if.tripla
Normal file
1
Project-02/triplaprograms/simple_if.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (true) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_2.tripla
Normal file
1
Project-02/triplaprograms/simple_if_2.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (true && false) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_3.tripla
Normal file
1
Project-02/triplaprograms/simple_if_3.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (true || false) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_4.tripla
Normal file
1
Project-02/triplaprograms/simple_if_4.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (1 > 2) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_5.tripla
Normal file
1
Project-02/triplaprograms/simple_if_5.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (2 > 3 + 5) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_6.tripla
Normal file
1
Project-02/triplaprograms/simple_if_6.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (1 > 2 || 3 < 5) then 1 else 0
|
||||
1
Project-02/triplaprograms/simple_if_7.tripla
Normal file
1
Project-02/triplaprograms/simple_if_7.tripla
Normal file
@@ -0,0 +1 @@
|
||||
if (2 == 0 == false) then 1 else 0
|
||||
2
Project-02/triplaprograms/square.tripla
Normal file
2
Project-02/triplaprograms/square.tripla
Normal file
@@ -0,0 +1,2 @@
|
||||
let square(x) { x*x }
|
||||
in square(10)
|
||||
4
Project-02/triplaprograms/validProgram.tripla
Normal file
4
Project-02/triplaprograms/validProgram.tripla
Normal file
@@ -0,0 +1,4 @@
|
||||
let mult(a,b) { a*b }
|
||||
add(a,b) { let inc(a) { if (b!=0) then b=b-1;inc(a+1) else mult(a,1) }
|
||||
in inc(a) }
|
||||
in add(mult(2,3),add(4,5))
|
||||
7
Project-02/triplaprograms/while.tripla
Normal file
7
Project-02/triplaprograms/while.tripla
Normal file
@@ -0,0 +1,7 @@
|
||||
let func(a,b) {
|
||||
while ( a > 0 && b != a ) do {
|
||||
b = b + 1;
|
||||
a = a - 1
|
||||
}
|
||||
}
|
||||
in func(10, 8)
|
||||
3
Project-02/triplaprograms/while_2.tripla
Normal file
3
Project-02/triplaprograms/while_2.tripla
Normal file
@@ -0,0 +1,3 @@
|
||||
while (true) do {
|
||||
3
|
||||
}
|
||||
8
Project-02/triplaprograms/wrapped-ggT.tripla
Normal file
8
Project-02/triplaprograms/wrapped-ggT.tripla
Normal file
@@ -0,0 +1,8 @@
|
||||
let wrapper(a, b) {
|
||||
let ggt(noneSense) {
|
||||
if a == b then a
|
||||
else
|
||||
if a > b then wrapper(a-b, b)
|
||||
else wrapper(b-a, a)
|
||||
} in ggt(0)
|
||||
} in wrapper(21, 49)
|
||||
9
Project-02/triplaprograms/wrapper.tripla
Normal file
9
Project-02/triplaprograms/wrapper.tripla
Normal file
@@ -0,0 +1,9 @@
|
||||
let wrapper(number, threshold) {
|
||||
let square(x) {
|
||||
if x*x > threshold
|
||||
then x
|
||||
else x*x
|
||||
}
|
||||
in square(number)
|
||||
}
|
||||
in wrapper(4, 10)
|
||||
Reference in New Issue
Block a user