def combinations(occurrences: List[(Char,Int)]): List[List[(Char,Int)]] = occurrences match {
case Nil => Nil
case x :: xs => for(z <- combinations(xs); y <- occ(x)) yield (y :: z)
}
def occ(e: (Char, Int)): List[(Char, Int)] = (for(i <- 0 to e._2) yield (e._1, i)).toList
喜用的理解,在斯卡拉
我無法找到在上面的代碼中的任何瑕疵,但它仍然給了我清單()進行任何輸入。
感謝諾亞的提示! – arpanchaudhury 2013-05-10 21:17:13