Created
April 6, 2014 19:48
-
-
Save davidallsopp/777680b92b4cf7c5f468 to your computer and use it in GitHub Desktop.
Creating convenient syntax for cross-products. From several postings including: https://stackoverflow.com/questions/14740199/cross-product-in-scala and https://stackoverflow.com/questions/2725682/cross-product-of-2-sets-in-scala, but see also https://stackoverflow.com/questions/13567543/cross-product-of-arbitrary-number-of-lists-in-scala for a s…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit class Crossable[X](xs: Traversable[X]) { | |
def cross[Y](ys: Traversable[Y]) = for { x <- xs; y <- ys } yield (x, y) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment