This commit is contained in:
2024-02-10 20:51:14 +01:00
parent 243bed60eb
commit 489ca42d32
19 changed files with 125 additions and 42 deletions

View File

@@ -3,7 +3,7 @@
<properties maven-id="org.openjfx:javafx-base:20-ea+2" /> <properties maven-id="org.openjfx:javafx-base:20-ea+2" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -3,11 +3,11 @@
<properties maven-id="org.openjfx:javafx-controls:22-ea+16" /> <properties maven-id="org.openjfx:javafx-controls:22-ea+16" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -3,9 +3,9 @@
<properties maven-id="org.openjfx:javafx-graphics:22-ea+16" /> <properties maven-id="org.openjfx:javafx-graphics:22-ea+16" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -11,5 +11,6 @@
<orderEntry type="library" name="openjfx.javafx.graphics" level="project" /> <orderEntry type="library" name="openjfx.javafx.graphics" level="project" />
<orderEntry type="library" name="openjfx.javafx.controls" level="project" /> <orderEntry type="library" name="openjfx.javafx.controls" level="project" />
<orderEntry type="library" name="scala-sdk-2.13.12" level="application" /> <orderEntry type="library" name="scala-sdk-2.13.12" level="application" />
<orderEntry type="library" name="scala-sdk-2.13.12" level="application" />
</component> </component>
</module> </module>

View File

@@ -2,13 +2,16 @@ package Klausur_ueb
object Lambda { object Lambda {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val a = Array(1, 2, 3, 4, 5) val a = Array(1.0, 2.0, 3.0, 4.0, 5.0)
val summe = a.reduce((x: Int, y: Int) => x + y) val summe = a.reduce((x: Double, y: Double) => x + y)
val summeKuerzer = a.reduce((x, y) => x + y) val summeKuerzer = a.reduce((x, y) => x + y)
val summeNochKuerzer = a.reduce(_ * _) val prodNochKuerzer = a.reduce(_ * _)
val qNochKuerzer = a.reduce(_ / _)
val summeGanzKurz = a.sum //vordefiniert val summeGanzKurz = a.sum //vordefiniert
println(summeGanzKurz) println(summeGanzKurz)
println(summeNochKuerzer) println(prodNochKuerzer)
println(qNochKuerzer)
println(1.0/120.0)
} }
} }

View File

@@ -4,19 +4,47 @@ import scala.annotation.tailrec
object FrenchDude { object FrenchDude {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
startPascal(5)
println(" ")
startPascal2(5)
} }
def pascalTriangle(c: Int, r: Int): Int = {
def startPascal(n:Int):Unit={
pascal(Array(1),n)
}
def startPascal2(n:Int):Unit={
pascal2(Array(1),n)
}
//Endrekursiv
@tailrec @tailrec
def loop(c0: Int, r0: Int, pred: Array[Int], cur: Array[Int]): Int = { def pascal (arr:Array[Int],n:Int): Unit = {
cur(c0) = (if (c0 > 0) pred(c0 - 1) else 0) + (if (c0 < r0) pred(c0) else 0) arr.foreach(v => print(v+" "))
var newArr = Array[Int]()
if ((c0 == c) && (r0 == r)) cur(c0) newArr = newArr :+ 1
else if (c0 < r0) loop(c0 + 1, r0, pred, cur) for (i <- arr.indices){
else loop(0, r0 + 1, cur, new Array(_length = r0 + 2)) if (i<arr.length-1)
newArr = newArr:+ arr(i)+arr(i+1)
}
newArr = newArr :+ 1
println()
if(newArr.length <= n+1)
pascal(newArr,n)
} }
if ((c == 0) && (r == 0)) 1 //Rekursiv, aber nicht Endrekursiv
else loop(0, 1, Array(1), Array(0, 0)) def pascal2 (arr:Array[Int],n:Int): Unit = {
arr.foreach(v => print(v+" "))
var newArr = Array[Int]()
newArr = newArr :+ 1
for (i <- arr.indices){
if (i<arr.length-1)
newArr = newArr:+ arr(i)+arr(i+1)
}
newArr = newArr :+ 1
println()
if(newArr.length <= n+1)
pascal2(newArr,n)
println()
} }
} }

View File

@@ -0,0 +1,45 @@
package P9
import scala.annotation.tailrec
object Counter {
def main(args: Array[String]) {
val arr = Array('a', 'b', 'a', 'a', 'c', 'c', 'c', 'b', 'b', 'a')
val arr2 = Array(1,1,1,3,3,2,2,1,1,4)
startCount(arr2)
println("Count 2: ")
startCount2(arr)
}
def startCount(arr: Array[?]): Unit = {
val dsArr = arr.distinct
val list: List[Int] = List()
count(arr, dsArr,0)
}
def startCount2(arr: Array[?]): Unit = {
val dsArr = arr.distinct
val list: List[Int] = List()
count2(arr, dsArr,0)
}
//Endrekursiv
@tailrec
def count(searchArr: Array[?], containArr: Array[?], index:Int): Unit = {
if (index >= containArr.length)
println("end")
else {
println(containArr(index).toString + ": " + searchArr.count(_==containArr(index)))
count(searchArr, containArr, index+1)
}
}
//Rekursiv, aber nicht Endrekursiv
def count2(searchArr: Array[?], containArr: Array[?], index:Int): Unit = {
if (index >= containArr.length)
println("end")
else {
count2(searchArr, containArr, index+1)
println(containArr(index).toString + ": " + searchArr.count(_==containArr(index)))
}
}
}

View File

@@ -1,10 +0,0 @@
package P9
object Numbers {
def main(args: Array[String]) {
println()
}
}

View File

@@ -1,12 +0,0 @@
object Palindrom {
def main(args: Array[String]) {
println(startCheck("ABCCBA"))
}
def startCheck(word: String): Boolean = {
check(0, word)
}
def check(i: Int, word: String): Boolean = {
if((word.length/2)<=i) true else if (word.charAt(i)==word.charAt(word.length-i-1)&&check(i+1,word)) true else false
}
}

View File

@@ -0,0 +1,28 @@
package P9
import scala.annotation.tailrec
object Palindrome {
def main(args: Array[String]): Unit = {
val word = "ABCDCBA"
println(startCheck(word))
println(startCheck2(word))
}
private def startCheck(word: String): Boolean = {
check(0, word)
}
private def startCheck2(word: String): Boolean = {
check2(0, word)
}
@tailrec
private def check(i: Int, word: String): Boolean = {
((word.length / 2) <= i) || (word.charAt(i) == word.charAt(word.length - i - 1) && check(i + 1, word)) //endrekursiv i guess
}
private def check2(i: Int, word: String): Boolean = {
((word.length / 2) <= i) || check2(i + 1, word) && (word.charAt(i) == word.charAt(word.length - i - 1)) //rekursiv, aber nicht endrekursiv
}
}