fork download
  1. object Main extends App {
  2. override def main(args:Array[String]) = {
  3. println( fix(1).take(10).toList )
  4. println( up(1).take(10).toList )
  5. println( up(10).take(20).filter(_%2==0).toList )
  6. println( up(10).filter(_%2==0).take(20).toList )
  7. }
  8. def fix(x:Int):Stream[Int] = x #:: fix(x)
  9. def up(x:Int):Stream[Int] = x #:: up(x+1)
  10. }
Success #stdin #stdout 0.38s 322176KB
stdin
Standard input is empty
stdout
List(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
List(10, 12, 14, 16, 18, 20, 22, 24, 26, 28)
List(10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48)