Created
May 20, 2019 21:28
-
-
Save Tok/ab5bcc92fb67a122e9d23c7683d2cfe2 to your computer and use it in GitHub Desktop.
Von Neumann ordinals as Kotlin Sets
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
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