blob: 1e05840ea3ee1e6d4e5b1f14e4210c9d82039801 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
|
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)
}
class TypedApply[T2]{
private def firstDiff[T <: TypedApply[T2]](xs: List[T]): Int = firstDiff(xs)
}
|