【问题标题】:Operator and operand don't agree ML运算符和操作数不一致 ML
【发布时间】:2017-06-28 02:30:51
【问题描述】:

我正在为类工作,我收到了这个错误。

错误:运算符和操作数不一致 [tycon mismatch]

运营商域:'Z 列表

操作数:'Y 列表 -> 'Y 列表

在表达式中: 空tl

fun removedub(L) =
  if (null L) then nil
  else if (null tl(L)) then hd(L)
  else if hd(L) = hd(tl(L)) then removedub(tl(L))
  else hd(L) :: removedub(tl(L));



val list = ["a", "a", "b", "b", "c"];

removedub(list);

我不确定如何解决这个问题,或者真的是什么原因造成的,有什么提示吗?

【问题讨论】:

    标签: ml


    【解决方案1】:

    你把括号弄错了。当你写

    null tl(L)
    

    那就和

    意思一样
    null(tl)(L)
    

    但是,你想要

    null(tl(L))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2021-05-17
      • 2018-04-28
      • 2023-03-15
      • 1970-01-01
      • 2018-02-11
      • 1970-01-01
      相关资源
      最近更新 更多