Compare commits

...

2 Commits

Author SHA1 Message Date
pl@gohorb.ba-horb.de
f496ff13b8 new file: ../applyLambda.jav
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 1m35s
2025-09-24 15:57:47 +02:00
pl@gohorb.ba-horb.de
642ecc9a50 modified: ../Id.jav
modified:   ../Main.jav
	modified:   ../OL.jav
	modified:   ../../../src/test/java/KPSPresentation.java
2025-09-24 15:57:22 +02:00
5 changed files with 84 additions and 36 deletions

View File

@@ -1,6 +1,5 @@
class Id { class Id {
id2 = x -> x; id2 = x -> x;
id4 = x -> x;
id(x) { id(x) {
return x; return x;

View File

@@ -3,40 +3,53 @@ import java.lang.System;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.Character; import java.lang.Character;
import java.lang.Object; import java.lang.Object;
import fst; import java.lang.Integer;
import fst;
import Id;
import OLMain;
import Fac
import Faculty; import Faculty;
//import FacultyBug; import applyLambda;
import java.lang.Float;
public class Main { public class Main {
public static main(x) { public static main(x) {
new fst().main(5); /*
//System.out.println(new Faculty().getFact(3)); new fst().main(5);
System.out.println(new fst().main(5));
//Id.jav: the identity-function
//applied to an integer //Id.jav: the identity-function
System.out.println(new Id().id(1).toString()); //applied to an integer
//applied to a string System.out.println(new Id().id(1));
System.out.println(new Id().id("hallo").toString()); //applied to a string
System.out.println(new Id().id("hallo"));
//OL.jav: Overloading //lamda-Expr
OLMain ol = new OLMain(); //System.out.println(new Id().id2.apply(1));
//the function main is applied to an integer //Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
System.out.println(ol.main(2));
//the main is applied to a double //OL.jav: Overloading
System.out.println(ol.main(2.0)); OLMain ol = new OLMain();
System.out.println(ol.main("Hallo"));
//the function main is applied to an integer
System.out.println(new Fac().getFac(6)); System.out.println(ol.main(2));
//the main is applied to a double
System.out.println(new Faculty().m().apply(6)); System.out.println(ol.main(2.0));
System.out.println(ol.main("Hallo"));
//Lambda.jav: An lambda expression applied by the method apply //Fac.jav
System.out.println(new Lambda().m().apply(77)); 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 //applyLambda.jav: A defined lambda expression is applied
System.out.println(new applyLambda().m()); System.out.println(new applyLambda().m());
*/
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>(); Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
Vector<Integer> v1 = new Vector<Integer> (); Vector<Integer> v1 = new Vector<Integer> ();
v1.addElement(2); v1.addElement(2);
@@ -69,15 +82,13 @@ public class Main {
//Matrix m3 = m1.mul(vv1); //Matrix m3 = m1.mul(vv1);
Matrix m3 = m1.mul(m2); Matrix m3 = m1.mul(m2);
System.out.println(m1.toString() + " * " + m2.toString() + " = " + m3.toString()); System.out.println(m1.toString() + " * " + m2.toString() + " = " + m3.toString());
/*
//MatrixOP //MatrixOP
MatrixOP mOp1 = new MatrixOP(); MatrixOP mOp1 = new MatrixOP();
mOp1.addElement(v1); mOp1.addElement(v1);
mOp1.addElement(v2); mOp1.addElement(v2);
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1); MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
System.out.println(m1.toString() + " * " + m2.toString() + " = " + mOp2.toString()); System.out.println(m1.toString() + " * " + m2.toString() + " = " + mOp2.toString());
}
} }
} }
@@ -86,5 +97,7 @@ public class MainBug {
System.out.println(new fst().main(5)); System.out.println(new fst().main(5));
//System.out.println(new FacultyBug().getFact(3)); //System.out.println(new FacultyBug().getFact(3));
} }
} */
}
}

View File

@@ -9,7 +9,7 @@ import java.lang.Object;
class OL { class OL {
Integer m(Integer x) { return x + x; } m(x) { return x + x; }
m(x) { return x || x; } m(x) { return x || x; }

View 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();
}
}

View File

@@ -54,18 +54,38 @@ public class KPSPresentation {
testAlgo("Main"); testAlgo("Main");
} }
@Test
public void fstTest() throws Exception {
testAlgo("fst");
}
@Test @Test
public void IdTest() throws Exception { public void IdTest() throws Exception {
testAlgo("Id"); testAlgo("Id");
} }
@Test
public void OLTest() throws Exception {
testAlgo("OL");
}
@Test
public void FacTest() throws Exception {
testAlgo("Fac");
}
@Test @Test
public void FacultyTest() throws Exception { public void FacultyTest() throws Exception {
testAlgo("Faculty"); testAlgo("Faculty");
} }
@Test @Test
public void FacultyBugTest() throws Exception { public void Lambda() throws Exception {
testAlgo("FacultyBug"); testAlgo("Lambda");
}
@Test
public void applyLambda() throws Exception {
testAlgo("applyLambda");
} }
} }