Skip to content

Instantly share code, notes, and snippets.

Avatar

kageru

View GitHub Profile
@kageru
kageru / kotlin-python-slice.kt
Created Jul 2, 2019
Mainly a proof of concept. There are better ways to do this, but it was a quick experiment to create something like Python’s slicing in Kotlin.
View kotlin-python-slice.kt
import kotlin.math.min
object start {
infix fun to(other: Int) = RangeTuple(0, other)
infix fun to(other: end) = RangeTuple(0, Int.MAX_VALUE)
}
object end
infix fun Int.to(other: end) = RangeTuple(this, Int.MAX_VALUE)