Scalaのforは直積集合を作るのに便利

scala> for(x <- 1 to 3; y <- 1 until 5){println(x + " " + y)}
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4

これはイケてる。