fork download
  1. import scala.util.control.TailCalls._
  2.  
  3.  
  4.  
  5. object Main {
  6. def isEven(xs: List[Int]): TailRec[Boolean] =
  7. if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail))
  8.  
  9. def isOdd(xs: List[Int]): TailRec[Boolean] =
  10. if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail))
  11.  
  12. def main(args: Array[String]) {
  13. println(isEven((1 to 100000).toList).result.toString)
  14. }
  15. }
Success #stdin #stdout 0.44s 383104KB
stdin
Standard input is empty
stdout
true