【发布时间】:2019-01-19 12:59:53
【问题描述】:
我有以下代码:
datatype complex = RealImg of real * real | Infinity;
fun divisionComplex(RealImg(a, b), RealImg(0.0, 0.0)) = Infinity
fun divisionComplex(RealImg(a, b), RealImg(c, d)) =
RealImg ((a * c + b * d) / (c * c + d * d), ((b * c) - (a * d))/ (c* c + d * d))
但是它失败了:
Error: syntax error: inserting EQUALOP
我很困惑。为什么会这样?我知道我无法比较 SML 中的两个实数,但我应该如何与 0 进行模式匹配?
【问题讨论】:
-
这个问题在Why can't I compare reals in Standard ML? 中得到了回答,在为什么模式中的实数不起作用[...]?使用ε。
-
谢谢!我已经标记了。
标签: functional-programming sml smlnj