A Solution to the Set Combinations Problem
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
}
blog comments powered by Disqus