Kotlin glue code that keeps me sane
| core | ||
| gradle/wrapper | ||
| pipelines | ||
| .gitignore | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| README.md | ||
| settings.gradle.kts | ||
Magik
This library adds many things I like from other languages to kotlin (such as monads and lenses) and also some general-purpose utility classes that I often find myself wanting.
There are also some more specific things, but those are in separate modules to keep the core lean and mean
Todo
Pipelines
Fix them
Pattern matching as a lib
class Match<T, R>(private val x: T) {
private var res: R? = null
infix fun case(pred: (T)->Boolean to (T)->R) {
if (res == null && pred.first(x)) res = pred.second(x)
}
fun otherwise(f: (T)->R): R = res ?: f(x)
}
fun <T,R> match(x: T, block: Match<T,R>.()->Unit): R =
Match<T,R>(x).apply(block).otherwise { error("No match") }
// usage
val label = match(42) {
case({ it % 2 == 0 } to { "even" })
case({ it > 100 } to { "big" })
}
Math Stuff
- Vectors
- Matrixes
- Tensors