Skip to content

Instantly share code, notes, and snippets.

@Tok
Created May 20, 2019 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tok/ab5bcc92fb67a122e9d23c7683d2cfe2 to your computer and use it in GitHub Desktop.
Save Tok/ab5bcc92fb67a122e9d23c7683d2cfe2 to your computer and use it in GitHub Desktop.
Von Neumann ordinals as Kotlin Sets
typealias VonNeumannOrdinal = Set<Any>
operator fun VonNeumannOrdinal.inc() = toMutableSet().also { it.add(this) }.toSet()
fun VonNeumannOrdinal.toInt() = this.size
fun VonNeumannOrdinal.print() = println("${toInt()} <- $this")
fun main() {
var ordinal = emptySet<Any>()
repeat(16) {
ordinal++.print()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment