Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created February 6, 2017 17:26
Show Gist options
  • Save khajavi/b2b30cbf3ea11b3b93d5e686ffc2f941 to your computer and use it in GitHub Desktop.
Save khajavi/b2b30cbf3ea11b3b93d5e686ffc2f941 to your computer and use it in GitHub Desktop.
def cross[T](list: Traversable[Traversable[T]]): Traversable[Traversable[T]] =
list match {
case x :: Nil => x map (List(_))
case x :: xs =>
for {
i <- x
j <- cross(xs)
} yield Traversable(i) ++ j
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment