开发者

Output is truncated with #-signs in the REPL

I wrote a function which works as expected but i don't unde开发者_开发百科rstand why the output is like that.

Function:

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


This is just an output restriction (yes, it's confusing) - by default the depth of value printouts in the top-level (interactive shell) is limited to a fairly small number (i.e. 5). The skipped parts are printed with #.

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

Control.Print.printDepth := 1024;

P.S. By the way, you don't need a separate do_xor and local function here - just

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

will do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜