Created
March 2, 2018 18:45
-
-
Save anicolaspp/eabf8933e7051537f7ddf78d66420ea7 to your computer and use it in GitHub Desktop.
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
object UsingExt { | |
import Ext._ | |
def factTwice(n: Int): BigInt = (n!)! | |
} | |
object Ext { | |
implicit class Ops(n: Int) { | |
def !(): BigInt = (1 to n).foldLeft(BigInt(1))(_ * _) | |
} | |
implicit class OpsBig(n: BigInt) { | |
def !(): BigInt = Ops(n.toInt)! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment