blob: 9cf373cf0ba46cd10ad9a24ccafd603fdf08c31f (
plain) (
blame)
1
2
3
4
5
|
class tailcall {
val shift = 1
final def fact(x: Int, acc: Int = 1): Int = if (x == 0) acc else fact(x - shift, acc * x)
def id[T <: AnyRef](x: T): T = if (x eq null) x else id(x)
}
|