Tuple2在递归Scala函数中被错误推断为乘积

Tuple2在递归Scala函数中被错误推断为乘积,scala,type-inference,Scala,Type Inference,我有一个函数可以从Tuple2[Char,Int]列表中创建组合 然而,当我对它进行递归调用时,我得到一个编译错误,元组被推断为产品 这是为什么?我怎样才能编译它 下面是编写示例的步骤 这编译为OK:- Welcome to Scala version 2.10.1 (OpenJDK 64-Bit Server VM, Java 1.7.0_17). Type in expressions to have them evaluated. Type :help for more informati

我有一个函数可以从Tuple2[Char,Int]列表中创建组合

然而,当我对它进行递归调用时,我得到一个编译错误,元组被推断为产品

这是为什么?我怎样才能编译它

下面是编写示例的步骤

这编译为OK:-

Welcome to Scala version 2.10.1 (OpenJDK 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def combos(a: List[(Char,Int)]): List[List[(Char,Int)]] = {
     |     if(a.isEmpty) List(List()) else {
     |       {
     |         for{
     |           x <- 0 to a.length
     |           (char,num) <- a take x
     |           rest = a drop x
     |           less <- num to 1 by -1           
     |         } yield (char,less) :: rest
     |       } toList
     |     }
     |   }
warning: there were 1 feature warning(s); re-run with -feature for details
combos: (a: List[(Char, Int)])List[List[(Char, Int)]]
欢迎使用Scala 2.10.1版(OpenJDK 64位服务器虚拟机,Java 1.7.017)。
键入要计算的表达式。
键入:有关详细信息的帮助。
scala>def组合(a:List[(Char,Int)]):List[List[(Char,Int)]={
|如果(a.isEmpty)List(List())else{
|       {
|为了{
|xrest的类型(组合的结果)是
List[List[(Char,Int)]
,并且您正在追加
(Char,Int)
,因此常见的推断类型是
Product

也许你的意思是休息谢谢你发现了!我是个白痴!我已经盯着看了好几个小时了!它发生了…没有什么比一双新眼睛更有趣的了:)
Welcome to Scala version 2.10.1 (OpenJDK 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def combos(a: List[(Char,Int)]): List[List[(Char,Int)]] = {
     |     if(a.isEmpty) List(List()) else {
     |       {
     |         for{
     |           x <- 0 to a.length
     |           (char,num) <- a take x
     |           rest = combos(a drop x)
     |           less <- num to 1 by -1          
     |         } yield (char,less) :: rest
     |       } toList 
     |     }
     |   }
<console>:17: error: type mismatch;
 found   : List[List[Product]]
 required: List[List[(Char, Int)]]
             } toList
               ^