Cross product in Scala
You can do this pretty straightforwardly with an implicit class and a for-comprehension in Scala 2.10: implicit class Crossable[X](xs: Traversable[X]) { def cross[Y](ys: Traversable[Y]) = for { x <- xs; y <- ys } yield (x, y) } val xs = Seq(1, 2) val ys = List(“hello”, “world”, “bye”) And now: scala> xs cross ys … Read more