diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 21f3d2f..1124cd7 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -10,10 +10,12 @@ + + diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..0dd4b35 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 6b69a17..8290633 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# fpgym +If MyDate were not a Comparable, and you omitted the operator modifier, comparing two dates via <, >, <=, or >= would not compile.# fpgym Functional Programming Gym diff --git a/functional-kotlin/pom.xml b/functional-kotlin/pom.xml new file mode 100644 index 0000000..e5b2f80 --- /dev/null +++ b/functional-kotlin/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + functional-kotlin + + + fpgym + org.gym.fp + 1.0 + + \ No newline at end of file diff --git a/functional-kotlin/src/main/java/KotlinTest.kt b/functional-kotlin/src/main/java/KotlinTest.kt new file mode 100644 index 0000000..3f9b25b --- /dev/null +++ b/functional-kotlin/src/main/java/KotlinTest.kt @@ -0,0 +1,54 @@ +import java.time.LocalDate + + +data class Person(val name: String, + val lastname: String, + val birthday: LocalDate) + +typealias Function = (T) -> R + +typealias BiFunction = (T, U) -> R + +inline class Amount(val quantity: Int) + +inline class Weight(val quantity: Int) + +inline class Password(val value: String) + +class UInt(val value: Int) { + init { + require(value >= 0) + } +} + +fun add(a: Int, b: Int): Int = a + b + +fun main() { + val (a, _) = Pair(1, 2) + println(a) + + val fabio = Person("Fabio", "Scotto", LocalDate.of(1988, 2, 17)) + val (name, lastname, _) = fabio + println("${name}, ${lastname}") + + when(fabio.name) { + "Fabio" -> println(fabio.name) + } + + each(UInt(5)) { + println("Hello") + } + +} + +operator fun Int.compareTo(other: UInt): Int { + return this.compareTo(other.value) +} + +fun each(times: UInt, block: () -> Unit) { + var i = 0 + while(i <= times) { + block() + i++ + } +} \ No newline at end of file diff --git a/functional-programming-java/pom.xml b/functional-programming-java/pom.xml index 8e30f35..6cfc135 100644 --- a/functional-programming-java/pom.xml +++ b/functional-programming-java/pom.xml @@ -1,20 +1,20 @@ - 4.0.0 - functional-programming-java - Questo modulo contiene gli esercizi e le prove dal libro "Functional Programmin in Java" - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + functional-programming-java + Questo modulo contiene gli esercizi e le prove dal libro "Functional Programmin in Java" + jar - - fpgym - org.gym.fp - 1.0 - + + fpgym + org.gym.fp + 1.0 + - - 8 + + 8 8