ML 之前在http://sml-family.org/Basis/general.html 中被描述为
a 在 b 返回 a 之前。它提供了一种符号简写,用于在返回 a 的值之前先计算 a,然后是 b。
当我尝试使用此命令时期望 x = 4 和 (4+1) 被评估
val x = (3+1 before 4+1)
Run Code Online (Sandbox Code Playgroud)
我有错误消息:
Standard ML of New Jersey v110.78 [built: Sun Apr 26 01:06:11 2015]
- stdIn:1.11-1.25 Error: operator and operand don't agree [overload conflict]
operator domain: [+ ty] * unit
operand: [+ ty] * [+ ty]
in expression:
(3 + 1 before 4 + 1)
-
Run Code Online (Sandbox Code Playgroud)
可能有什么问题?
根据马特的回答,我应该使用
val x = (3+1 …Run Code Online (Sandbox Code Playgroud) 我有这个SML/NJ代码从文本文件中读取一行,然后它会为我返回一个列表,但我无法让它对每一行做同样的事情,并在没有更多行时停止.有人可以通过在这里给我一个循环样本来帮助我吗?
fun readlist(infile : string) =
let val ins = TextIO.openIn infile
val list = []
fun listing() = [TextIO.inputLine ins]::list;
in listing()
end
Run Code Online (Sandbox Code Playgroud)