val r = new Random(System.currentTimeMillis()) def rand(max:Int):Stream[Int] = Stream.cons(r.nextInt(max), rand(max)) rand(100) take 10 foreach println // assign index starting from 1. zipWithIndex()'s index starts from 0 rand(50) take 5 zip(Stream from 1) foreach println
0 件のコメント:
コメントを投稿