Scala 有人能给我解释一下中间的界线吗**?我不明白地图是怎么工作的

Scala 有人能给我解释一下中间的界线吗**?我不明白地图是怎么工作的,scala,map,Scala,Map,.mapocc._1,_是.mapi=>occ._1,i的缩写 对于0和occ.\u 2之间的每个元素,它创建一个元组,如上所述。这将返回一个元组列表,其中第一个元素固定,第二个元素从0到occ 例如: def combinations(occurrences: Occurrences): List[Occurrences] = occurrences match { case List() => List(List()) case occ :: occs =>

.mapocc._1,_是.mapi=>occ._1,i的缩写

对于0和occ.\u 2之间的每个元素,它创建一个元组,如上所述。这将返回一个元组列表,其中第一个元素固定,第二个元素从0到occ

例如:

def combinations(occurrences: Occurrences): List[Occurrences] = occurrences match {  
    case List() => List(List())
    case occ :: occs =>
        for {
            **occSub <- (0 to occ._2).map((occ._1, _)).toList**
            occsCombination <- combinations(occs)
            } yield (occSub :: occsCombination).filter(x => x._2 != 0)
}
.mapocc._1,_是.mapi=>occ._1,i的缩写

对于0和occ.\u 2之间的每个元素,它创建一个元组,如上所述。这将返回一个元组列表,其中第一个元素固定,第二个元素从0到occ

例如:

def combinations(occurrences: Occurrences): List[Occurrences] = occurrences match {  
    case List() => List(List())
    case occ :: occs =>
        for {
            **occSub <- (0 to occ._2).map((occ._1, _)).toList**
            occsCombination <- combinations(occs)
            } yield (occSub :: occsCombination).filter(x => x._2 != 0)
}