fork(1) download
  1. import Stream._
  2.  
  3. object Main {
  4. def incLast(list: Stream[Int]): Stream[Int] = list match {
  5. case Empty => Empty
  6. case x #:: Empty => Stream(x + 1)
  7. case x #:: xs => x #:: incLast(xs)
  8. }
  9.  
  10. def main(args: Array[String]): Unit =
  11. {
  12. println(s"${incLast(Stream.range(1, 10000)).last}")
  13. }
  14. }
Success #stdin #stdout 0.4s 321984KB
stdin
Standard input is empty
stdout
10000