I'm trying to use SML/NJ, and I use sml < source.sml
to run the code, but it prints out too much information.
For example, this is the source.sml
:
fun fac 0 = 1
| fac n = n * fac (n - 1)
val r = fac 10 ;
print(Int.toString(r));
This is the output:
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
From Suppress "val it" output in Standard ML, How to disable SMLNJ warnings?, and SMLNJ want to remove "val it = () : unit" from every print statement execution, I got some hints how to suppress them.
I execute CM_VERBOSE=false sml < $filename
and added one line of Control.Print.out := {say=fn _=>(), flush=fn()=>()};
in the code, but I still have some message:
Standard ML of New Jersey v110.77 [built: Tue Mar 10 07:03:24 2015]
- 3628800
How can I print out only the output?