Compare commits
4 Commits
a0e59eebe8
...
KPS2025
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c519d0746 | ||
|
|
db040d590e | ||
|
|
f496ff13b8 | ||
|
|
642ecc9a50 |
7
resources/AllgemeinTest/Uncurrier.jav
Normal file
7
resources/AllgemeinTest/Uncurrier.jav
Normal file
@@ -0,0 +1,7 @@
|
||||
public class Uncurrier{
|
||||
uncurry (f){
|
||||
return x -> f.apply(x);}
|
||||
uncurry (f){
|
||||
return (x, y) -> f.apply(x).apply(y);
|
||||
}
|
||||
}
|
||||
9
resources/AllgemeinTest/UncurrierMain.jav
Normal file
9
resources/AllgemeinTest/UncurrierMain.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
import Uncurrier;
|
||||
import java.lang.Integer;
|
||||
|
||||
class UncurrierMain {
|
||||
meth(y) {
|
||||
var uc = new Uncurrier() ;
|
||||
uc.uncurry(x -> x+1);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Float;
|
||||
|
||||
import java.lang.Double;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Faculty {
|
||||
public Fun1$$<Integer, Integer> fact = (x) -> {
|
||||
public Fun1$$<Double, Double> fact = (x) -> {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return x * (fact.apply(x-1));
|
||||
return x * (fact.apply(x-1.0));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,4 +17,9 @@ public class Faculty {
|
||||
return fact.apply(x);
|
||||
}
|
||||
|
||||
public static void main(x) {
|
||||
var f = new Faculty();
|
||||
var intRes = f.getFact(3.0);
|
||||
System.out.println(intRes);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
class Id {
|
||||
id2 = x -> x;
|
||||
id4 = x -> x;
|
||||
|
||||
id(x) {
|
||||
return x;
|
||||
|
||||
@@ -3,40 +3,56 @@ import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Character;
|
||||
import java.lang.Object;
|
||||
import fst;
|
||||
import java.lang.Integer;
|
||||
import fst;
|
||||
import Id;
|
||||
import OLMain;
|
||||
import Fac;
|
||||
import Faculty;
|
||||
//import FacultyBug;
|
||||
import java.lang.Float;
|
||||
import applyLambda;
|
||||
import java.util.Vector;
|
||||
import Matrix;
|
||||
import MatrixOP;
|
||||
|
||||
public class Main {
|
||||
public static main(x) {
|
||||
new fst().main(5);
|
||||
//System.out.println(new Faculty().getFact(3));
|
||||
|
||||
//Id.jav: the identity-function
|
||||
//applied to an integer
|
||||
System.out.println(new Id().id(1).toString());
|
||||
//applied to a string
|
||||
System.out.println(new Id().id("hallo").toString());
|
||||
|
||||
//OL.jav: Overloading
|
||||
OLMain ol = new OLMain();
|
||||
//the function main is applied to an integer
|
||||
System.out.println(ol.main(2));
|
||||
//the main is applied to a double
|
||||
System.out.println(ol.main(2.0));
|
||||
System.out.println(ol.main("Hallo"));
|
||||
|
||||
System.out.println(new Fac().getFac(6));
|
||||
|
||||
System.out.println(new Faculty().m().apply(6));
|
||||
|
||||
//Lambda.jav: An lambda expression applied by the method apply
|
||||
System.out.println(new Lambda().m().apply(77));
|
||||
/*
|
||||
new fst().main(5);
|
||||
System.out.println(new fst().main(5));
|
||||
|
||||
//Id.jav: the identity-function
|
||||
//applied to an integer
|
||||
System.out.println(new Id().id(1));
|
||||
//applied to a string
|
||||
System.out.println(new Id().id("hallo"));
|
||||
//lamda-Expr
|
||||
//System.out.println(new Id().id2.apply(1));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
|
||||
//OL.jav: Overloading
|
||||
OLMain ol = new OLMain();
|
||||
|
||||
//the function main is applied to an integer
|
||||
System.out.println(ol.main(2));
|
||||
//the main is applied to a double
|
||||
System.out.println(ol.main(2.0));
|
||||
System.out.println(ol.main("Hallo"));
|
||||
//Fac.jav
|
||||
System.out.println(new Fac().getFac(6));
|
||||
|
||||
|
||||
//Faculty.jav
|
||||
//System.out.println(new Faculty().fact.apply(6));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
System.out.println(new Faculty().getFact(3));
|
||||
|
||||
//Lambda.jav: An lambda expression applied by the method apply
|
||||
//System.out.println(new Lambda().m().apply(77));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
|
||||
//applyLambda.jav: A defined lambda expression is applied
|
||||
System.out.println(new applyLambda().m());
|
||||
|
||||
*/
|
||||
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||
Vector<Integer> v1 = new Vector<Integer> ();
|
||||
v1.addElement(2);
|
||||
@@ -69,22 +85,22 @@ public class Main {
|
||||
//Matrix m3 = m1.mul(vv1);
|
||||
Matrix m3 = m1.mul(m2);
|
||||
System.out.println(m1.toString() + " * " + m2.toString() + " = " + m3.toString());
|
||||
|
||||
|
||||
//MatrixOP
|
||||
MatrixOP mOp1 = new MatrixOP();
|
||||
mOp1.addElement(v1);
|
||||
mOp1.addElement(v2);
|
||||
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
|
||||
System.out.println(m1.toString() + " * " + m2.toString() + " = " + mOp2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public class MainBug {
|
||||
public static main(x) {
|
||||
System.out.println(new fst().main(5));
|
||||
//System.out.println(new FacultyBug().getFact(3));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
11
resources/KPSPresentation/MainFaculty.jav
Normal file
11
resources/KPSPresentation/MainFaculty.jav
Normal file
@@ -0,0 +1,11 @@
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import Faculty;
|
||||
|
||||
public class MainFaculty {
|
||||
public static void main(x) {
|
||||
//var f = new Faculty();
|
||||
//var intRes = f.getFact(3);
|
||||
//System.out.println(intRes);
|
||||
}
|
||||
}
|
||||
20
resources/KPSPresentation/MainOL.jav
Normal file
20
resources/KPSPresentation/MainOL.jav
Normal file
@@ -0,0 +1,20 @@
|
||||
import java.lang.String ;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Float;
|
||||
import OL2;
|
||||
|
||||
class MainOL {
|
||||
public static main(x) {
|
||||
var ol = new OL2();
|
||||
|
||||
//the function main is applied to an integer
|
||||
//var res1 = ol.m2(2);
|
||||
//the main is applied to a double
|
||||
//System.out.println(ol.m2(2.0));
|
||||
//System.out.println(ol.m2("Hallo").toString());
|
||||
var res2 = ol.m2("Hallo").toString();
|
||||
System.out.println(res2);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import java.lang.Boolean;
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
|
||||
Matrix () {
|
||||
public Matrix () {
|
||||
}
|
||||
|
||||
Matrix(vv) {
|
||||
public Matrix(vv) {
|
||||
var i = 0;
|
||||
while(i < vv.size()) {
|
||||
this.add(vv.elementAt(i));
|
||||
@@ -17,7 +17,7 @@ public class Matrix extends Vector<Vector<Integer>> {
|
||||
}
|
||||
|
||||
|
||||
mul(java.util.Vector<? extends java.util.Vector<? extends java.lang.Integer>> m) {
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Byte;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
|
||||
MatrixOP () {
|
||||
public MatrixOP () {
|
||||
}
|
||||
|
||||
MatrixOP(vv) {
|
||||
public MatrixOP(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
@@ -17,7 +20,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
}
|
||||
}
|
||||
|
||||
Fun2$$<Vector<? extends Vector<? extends Integer>>, Vector<? extends Vector<? extends Integer>>, MatrixOP> mul = (m1, m2) -> {
|
||||
mul = (m1, m2) -> {
|
||||
var ret = new MatrixOP();
|
||||
var i = 0;
|
||||
while(i < m1.size()) {
|
||||
@@ -39,4 +42,23 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
public static main(x) {
|
||||
var vv = new Vector<Vector<Integer>>();
|
||||
var v1 = new Vector<Integer> ();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
var v2 = new Vector<Integer> ();
|
||||
v2.addElement(3);
|
||||
v2.addElement(3);
|
||||
|
||||
//MatrixOP
|
||||
MatrixOP mOp1 = new MatrixOP();
|
||||
mOp1.addElement(v1);
|
||||
mOp1.addElement(v2);
|
||||
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
|
||||
System.out.print(mOp1); System.out.print(" * "); System.out.print(mOp1); System.out.print(" = "); System.out.println(mOp2);
|
||||
//System.out.print(mOp1 + " * " + mOp1 + " = " + mOp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,31 @@ import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Object;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
|
||||
|
||||
|
||||
class OL {
|
||||
public class OL1 {
|
||||
|
||||
Integer m(Integer x) { return x + x; }
|
||||
m1( x) { return x + x; }
|
||||
|
||||
|
||||
m(x) { return x || x; }
|
||||
m1(x) { return x || x; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class OLMain {
|
||||
public class OL2 {
|
||||
|
||||
main(x) {
|
||||
m2(x) {
|
||||
var ol;
|
||||
ol = new OL();
|
||||
return ol.m(x);
|
||||
ol = new OL1();
|
||||
return ol.m1(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
16
resources/KPSPresentation/applyLambda.jav
Normal file
16
resources/KPSPresentation/applyLambda.jav
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.util.Vector;
|
||||
class Apply { }
|
||||
|
||||
public class applyLambda {
|
||||
|
||||
public m () {
|
||||
var lam1 = (x) -> {
|
||||
return x;
|
||||
};
|
||||
|
||||
return lam1.apply(new Apply());
|
||||
//return lam1;
|
||||
//return new Vector();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,18 +54,58 @@ public class KPSPresentation {
|
||||
testAlgo("Main");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fstTest() throws Exception {
|
||||
testAlgo("fst");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void IdTest() throws Exception {
|
||||
testAlgo("Id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void OLTest() throws Exception {
|
||||
testAlgo("OL");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MainOLTest() throws Exception {
|
||||
testAlgo("MainOL");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FacTest() throws Exception {
|
||||
testAlgo("Fac");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FacultyTest() throws Exception {
|
||||
testAlgo("Faculty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FacultyBugTest() throws Exception {
|
||||
testAlgo("FacultyBug");
|
||||
public void MainFacultyTest() throws Exception {
|
||||
testAlgo("MainFaculty");
|
||||
}
|
||||
@Test
|
||||
public void LambdaTest() throws Exception {
|
||||
testAlgo("Lambda");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyLambdaTest() throws Exception {
|
||||
testAlgo("applyLambda");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MatrixTest() throws Exception {
|
||||
testAlgo("Matrix");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MatrixOPTest() throws Exception {
|
||||
testAlgo("MatrixOP");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user