Created
January 15, 2017 15:21
-
-
Save matklad/9c283f5cd2dfdac7635671e0b5d1b0ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Zn(private val modulus: Int) { | |
fun int(x: Int): ZnInt = ZnInt(x % modulus) | |
operator fun ZnInt.plus(rhs: ZnInt): ZnInt = int(this.value + rhs.value) | |
} | |
class ZnInt(val value: Int) | |
fun main(args: Array<String>) { | |
val ring = Zn(92) | |
ring.run { | |
val x = int(62) | |
val y = int(111) | |
println(x + y) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment