combinations

trait Collection[A] {
  def combinations(k: Int): Iterator[Collection[A]]
}

combinations computes all the possible combinations of this collection’s elements taking k elements at a time and returns an Iterator to iterate them.