【发布时间】:2020-02-26 05:40:11
【问题描述】:
我正在尝试学习 SML,并且正在尝试实现两个功能。第一个函数工作正常,但是当我添加第二个函数时,它给了我一个运行时错误:
stdIn:1.2-1.17 Error: unbound variable or constructor: number_in_month
这发生在调用函数 number_in_month 时。我的代码是:
fun is_older(d1 :int*int*int,d2 :int*int*int) =
(#1 d1) < (#1 d2) andalso (#2 d1) < (#2 d2) andalso (#3 d1) < (#3 d2)
fun number_in_month(da :(int * int * int) list ,mo : int) =
if da = []
then 0
else if (#2(hd da)) = mo
then 1 + number_in_month((tl da),mo)
else 0 + number_in_month((tl da),mo)
【问题讨论】:
-
你确定你得到的错误指向这个代码吗?此外,未绑定的变量在 SML 中肯定不会出现运行时错误。
-
代码运行良好。该错误意味着该函数未定义。也许您只是忘记重新加载文件。
标签: sml