e.map{case p => e′ } — The Scala Language Specification Version 2.9 / 6.19 For Comprehensions and For Loops for(p <- e; p′ <- e′;…) yield e′′ e.flatMap{ case p => for(p′ <- e′;…) yield e′′ } p <- e if g p <- e.withFilter((x1 ,…,xn ) => g)
1 until i if isPrime(i + j) } yield (i, j) (1 until n) .flatMap { case i => for (j <- 1 until i if isPrime(i + j)) yield (i, j) } for(p <- e; p′ <- e′;…) yield e′′ e.flatMap{ case p => for(p′ <- e′;…) yield e′′ }
<- 1 until i if isPrime(i + j)) yield (i, j) } p <- e if g p <- e.withFilter((x1 ,…,xn ) => g) (1 until n) .flatMap { case i => for (j <- (1 until i) .withFilter { j => isPrime(i + j) } ) yield (i, j) }
1 until i if isPrime(i + j) } yield (i, j) (1 until n) .flatMap { case i => (1 until i) .withFilter { j => isPrime(i + j) } .map { case j => (i, j) } }
p => e′ } for(p <- e; p′ <- e′;…) yield e′′ e.flatMap{ case p => for(p′ <- e′;…) yield e′′ } p <- e if g p <- e.withFilter((x1 ,…,xn ) => g) ˠ0QUJPOܕΛ͍͜ͳͯ͠ॳ৺ऀ͔Βதڃऀ 4DBMBԬ — The Scala Language Specification Version 2.9 / 6.19 For Comprehensions and For Loops