This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by smallufo on 2019-11-06. | |
*/ | |
package destiny | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.* | |
import mu.KotlinLogging | |
import org.apache.http.client.fluent.Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FamilyReaderTest { | |
enum class Gender { M, F } | |
data class Family( | |
val father: String?, | |
val mother: String?, | |
val children: Set<Pair<Gender, String>>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun chunk(lines: Sequence<String>): Sequence<Family> = sequence { | |
var father: String? = null | |
var mother: String? = null | |
val children = mutableSetOf<Pair<Gender, String>>() | |
lines.forEach { line -> | |
val tokens = line.split("[ \t]".toRegex()) | |
val token0 = tokens[0] | |
if ((token0 == "F" || token0 == "M") && (children.isNotEmpty() || (father != null && mother != null))) { | |
yield(Family(father, mother, children.toSet())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Gender { M, F } | |
data class Family( | |
val father: String?, | |
val mother: String?, | |
val children: Set<Pair<Gender, String>>) | |
fun read() { | |
javaClass.getResourceAsStream("families.txt").bufferedReader(Charsets.UTF_8).useLines { lines -> | |
lines.filterNot { it.startsWith("#") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# notes started with `#` | |
F Andy | |
M Babara | |
S Christ | |
D Dayna | |
F Andrew | |
M Barbie | |
S Charles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# notes started with `#` | |
F Andy | |
M Babara | |
S Christ | |
D Dayna | |
F Andrew | |
M Barbie | |
S Charles | |
S Daniel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.stereotype.Component | |
import javax.inject.Inject | |
class MyService(val mailImpl : Mailer) { | |
fun doSomething() { | |
// do something | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test | |
class CarBikeTest2 { | |
enum class CarVendor { Audi, BMW, Benz } | |
enum class CarType { Sedan, Coupe, HatchBack } | |
data class Car(val vendor: CarVendor, | |
val model: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test | |
class CarBikeTest { | |
enum class CarVendor { Audi, BMW, Benz } | |
enum class CarType { Sedan, Coupe, HatchBack } | |
data class Car(val vendor: CarVendor, | |
val model: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test | |
class CarTest { | |
enum class Vendor { Audi, BMW, Benz } | |
enum class Type { Sedan, Coupe, HatchBack } | |
data class Car(val vendor: Vendor, | |
val model: String, |