【发布时间】:2021-07-11 18:20:02
【问题描述】:
我正在尝试在 SML 中编写模式匹配函数,但出现此错误
Error: non-constructor applied to argument in pattern: -
我正在尝试做这样的事情:
fun illegal (c:char) i j n m =
let
fun legal (#"A") 0 j = true
|legal (#"B") i 0 = true
|legal (#"C") i n = true
|legal (#"D") m j = true
| legal c i j = false
in
if (legal c i j = false) then 0
else i
end
**I suspect that the problem is that my n,m are two constants that have been valued right before. Any help appreciated
(I searched online and here I added parentheses in my chars, and tried some other stuff but my error persisted)**
【问题讨论】:
-
我看到了两种可能性:错误是指其他内容,或者您的原始代码有一个拼写错误,在您发布时已修复。