Skip to content

Instantly share code, notes, and snippets.

@chrislewis
Created September 30, 2009 03:33
Show Gist options
  • Select an option

  • Save chrislewis/197738 to your computer and use it in GitHub Desktop.

Select an option

Save chrislewis/197738 to your computer and use it in GitHub Desktop.
def combine[T](sets: List[List[T]]): List[List[T]] = sets match {
case List(l1, l2) => l1.flatMap(i1 => l2.map(List(i1, _)))
case head :: tail => combine(tail).flatMap(set => head.map(_ :: set))
case _ => sets
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment