Skip to content

Instantly share code, notes, and snippets.

Avatar
🍵

Valentin Michalak vmichalak

🍵
View GitHub Profile
@vmichalak
vmichalak / Spintax.kt
Last active Apr 25, 2018
Spintax parser
View Spintax.kt
import java.util.*
fun main(args: Array<String>) {
(1..10).forEach { println(spin("my {little|big} pony")) }
}
fun spin(value: String): String {
var result: String = value
val random: Random = Random()
val regex: Regex = Regex("\\{[^{}]*}")
View Random.kt
import kotlin.math.floor
/**
* This class implement a Linear Congruential Generator.
*
* @author Valentin Michalak
*/
class Random(private var seed: Long = 0) {
companion object {