'int 是什么?树'在 SML 错误消息中是什么意思?

编程入门 行业动态 更新时间:2024-10-24 12:31:59
本文介绍了'int 是什么?树'在 SML 错误消息中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我为一个班级编写了以下 SML 代码:

I have the following SML code that I wrote for a class:

fun lookup (cmp: 'a * 'a -> order) (x: 'a, t: 'a tree) : 'a option =
    case t of
      Empty => NONE
    | Node(l,y,r) =>
      case cmp(x,y) of
        EQUAL => SOME y
      | LESS => lookup (cmp) (x,r)
      | GREATER => lookup (cmp) (x,l)

在测试中:

val SOME 3 = lookup Intpare (3, Node(Empty,3,Empty));

并返回以下错误:

stdIn:153.1-166.12 Error: operator and operand don't agree [tycon mismatch]
  operator domain: int * int ?.tree
  operand:         int * int tree
  in expression:
    (lookup Intpare) (3,Node (Empty,3,Empty))

?. 是什么意思?

推荐答案

这通常与跨模块的可见性受限有关.你的树"定义是什么样的?您可能需要告诉编译器您在一个模块中的树"类型与另一个模块中的相同.

This is usually to do with restricted visibility across modules. What does your 'tree' definition look like? You might need to tell the compiler that your 'tree' type in one module is the same as the one in another module.

这篇关于'int 是什么?树'在 SML 错误消息中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 13:00:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1409414.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   消息   int   SML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!