The output is truncated by C # characters in REPL

I wrote a function that works as expected, but I don’t understand why the output is like this.

Functions:

datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop; (* XOR = (A And Not B) OR (Not A Or B) *) local fun do_xor (alpha,beta) = Or( And( alpha, Not(beta) ), Or(Not(alpha), beta)) in fun xor (alpha,beta) = do_xor(alpha,beta); end; 

Test:

 val result = xor(Atom "a",Atom "b"); 

Output:

 val result = Or (And (Atom #,Not #),Or (Not #,Atom #)) : prop 
+7
source share
1 answer

This is just an exit restriction (yes, it is confusing) - by default, printouts of the depth of values ​​at the top level (interactive shell) are limited to a rather small number (i.e. 5). Missing parts are printed on #.

You can override this depth - at least in SML-NJ - with the variable printDepth:

 Control.Print.printDepth := 1024; 

PS By the way, you do not need a separate do_xor and a local function here - just

 fun xor(alpha, beta) = Or(...); 

will do.

+14
source

All Articles