我目前正在从Coursera的Odersky课程做作业。我已经定义了以下方法:
def encode(tree: CodeTree)(text: List[Char]): List[Bit] = encodeAcc(tree, tree , text, List())
def encodeAcc(tree: CodeTree, treeAcc: CodeTree, text: List[Char], bits: List[Bit]): List[Bit] = (treeAcc, text) match {
case (Leaf(char, _), t :: ts) => {
if(char == t) bits ++ encodeAcc(tree, tree, ts, List())
else null
}
case (Fork(left, right, chars, bits)) => encodeAcc(tree, left, text, bits ++ List(0)) ++
encodeAcc(tree, left, text, bits ++ List(1))
}
其中
type Bit = Int
但是,我在bits ++ List(0)
和bits ++ List(1)
Cannot resolve symbol ++
上的最后两行收到2个错误。
为什么我不能附上这些名单?