Skip to content

Instantly share code, notes, and snippets.

@anicolaspp
Created March 2, 2018 18:45
Show Gist options
  • Save anicolaspp/eabf8933e7051537f7ddf78d66420ea7 to your computer and use it in GitHub Desktop.
Save anicolaspp/eabf8933e7051537f7ddf78d66420ea7 to your computer and use it in GitHub Desktop.
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