我正在尝试使用SML/NJ,使用sml < source.sml
运行代码,但它会输出太多信息。
例如,这是source.sml
的内容:
fun fac 0 = 1
| fac n = n * fac (n - 1)
val r = fac 10 ;
print(Int.toString(r));
这是输出结果:
Standard ML of New Jersey v110.77 [built: Tue Mar 10 07:03:24 2015]
- val fac = fn : int -> int
val r = 3628800 : int
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[autoloading done]
3628800val it = () : unit
从Suppress "val it" output in Standard ML,How to disable SMLNJ warnings?和SMLNJ want to remove "val it = () : unit" from every print statement execution中,我获得了一些关于如何抑制它们的提示。我执行
CM_VERBOSE=false sml < $filename
并在代码中添加了一行Control.Print.out := {say=fn _=>(), flush=fn()=>()};
,但仍然有一些消息:Standard ML of New Jersey v110.77 [built: Tue Mar 10 07:03:24 2015]
- 3628800
我该如何仅打印输出结果?