PPaste!

Home - All the pastes - Authored by Thooms

Raw version

1
2
3
4
5
6
  def combinations(occurrences: Occurrences): List[Occurrences] =
    (Nil :: (for {
      occurrence <- occurrences
      rest <- combinations(occurrences.filterNot(_._1 == occurrence._1))
      n <- 1 to occurrence._2
    } yield (occurrence._1, n) :: rest).map(_.sorted)).distinct