I think the code below is what you are actually looking for ... I think the compiler is finishing translating it into the equivalent of the map code that Rex gave, but closer to the syntax of your original example:
scala> def doIt(i:Int, j:Int) = { println(i + ","+j); (i,j); } doIt: (i: Int, j: Int)(Int, Int) scala> def x = for( i <- (1 to 5).iterator; j <- (1 to 5).iterator ) yield doIt(i,j) x: Iterator[(Int, Int)] scala> x.foreach(print) 1,1 (1,1)1,2 (1,2)1,3 (1,3)1,4 (1,4)1,5 (1,5)2,1 (2,1)2,2 (2,2)2,3 (2,3)2,4 (2,4)2,5 (2,5)3,1 (3,1)3,2 (3,2)3,3 (3,3)3,4 (3,4)3,5 (3,5)4,1 (4,1)4,2 (4,2)4,3 (4,3)4,4 (4,4)4,5 (4,5)5,1 (5,1)5,2 (5,2)5,3 (5,3)5,4 (5,4)5,5 (5,5) scala>
You can see at the output that printing in "doIt" is not called until the next x value is iterated, and this style for the generator is a little easier to read / write than a bunch of nested cards.