1 fun max(a,b,c) =
2 if a > b andalso a > c then a
3 else if b > a andalso b > c then b
4 else c
5
6
6 val x = max(1,_,3);我用SML编写了一个max函数,它需要三个数字。如果我输入3个整数,它就会工作得很好。但是,如果我给这个函数一个通配符,它会抛出以下异常:max.sml:6.15 Error: syntax error: replacing WILD with EQUALOP
为什么会这样呢?
发布于 2015-01-15 12:39:23
通配符仅用于模式匹配。它们不能用作表达式,因为它们不能计算为值。
https://stackoverflow.com/questions/27956403
复制相似问题