找到的单位:必填[SomethingElse]

气泡

我有以下scala函数,由于它发现Unit甚至需要它,所以它不会编译[SomethingElse]

def combine(trees: List[CodeTree]): List[CodeTree] = {

  if(trees.length < 2) trees
  else isortForTrees(trees.+:(new Fork(trees.head, trees.tail.head, chars(trees.head).:::(chars(trees.tail.head)), weight(trees.head) + weight(trees.tail.head)))) 

  def isortForTrees(myList: List[CodeTree]): List[CodeTree] = {
    if(myList.isEmpty) Nil
    else insertForTrees(myList.head, isortForTrees(myList.tail))
  }

  def insertForTrees(toBeInserted: CodeTree, lisToBe: List[CodeTree]): List[CodeTree] = {
    if(lisToBe.isEmpty || weight(toBeInserted) < weight(lisToBe.head)) toBeInserted :: lisToBe
    else lisToBe.head :: insertForTrees(toBeInserted, lisToBe.tail)
  }

}

我不明白为什么要归还单位?if语句的两端都返回List [CodeTree]。我可能犯了一个愚蠢的错误,但我根本找不到。我在这里想念什么?

糖蛋白

方法中的最后一个表达式是返回的方法定义Unit随便走

if(trees.length < 2) trees
else isortForTrees(trees.+:(new Fork(trees.head, trees.tail.head, chars(trees.head).:::(chars(trees.tail.head)), weight(trees.head) + weight(trees.tail.head))))

到方法的底部,它应该可以工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

找到单位但需要双倍

错误:必填:图片,找到:图片可打包

必填:无参数,找到:字符串

确切的API-SalesOrderLines(项目必填:单位),即使单位存在

如何找到此编号的CSS单位

OpenCSV标头缺少找到的必填字段[]

在Selenium Webdriver中找到必填字段的标签文本

如何找到Java中的货币子单位(又称小单位)符号?

将以不同单位找到的坐标数据帧转换为一个单位

在Ghostscript / Postscript中找到字体的下标大小(以磅为单位)?

用于理解的 Scala 返回类型不匹配;找到:单位

错误:类型不匹配;找到:Unit.type必需:单位

Kotlin类型不匹配:必需,长期未找到单位

如何以像素为单位找到轴的交叉点

类型不匹配,必需:上下文,找到:单位

Android Kotlin:必填上下文,但找到了字符串

“错误的第一个参数类型。找到:'android.widget.Compoundbutton.oncheckedchangelistener',必填:'android.content.context'”

在PostgreSQL中找到时间戳之间的差异(以秒为单位)

如何通过对 Laravel 中的库存单位进行分组来找到最畅销的产品?

找到Scala Spark类型不匹配的单位,必需为rdd.RDD

如何找到填充一个区域的单位的最平方解?

无法启动 gunicorn.service:未找到单位 gunicorn.service。乌本托 18.04

在给定卡车箱尺寸的情况下,找到可以装满卡车的最大单位数

scrutinee与模式类型不兼容;找到:package.SomeObject必需:单位

如何找到Sprite和屏幕角之间的距离(以像素为单位)?

如何以分钟为单位找到 Scala java.util.Date 差异?

mapAsync 类型不匹配;找到:所需单位:scala.concurrent.Future

如何在SQL Server中的两个交叉列之间找到以秒为单位的时间

如何使用ruby从两个日期时间戳字段中找到以毫秒为单位的时差