Output is truncated with #-signs in the REPL

不打扰是莪最后的温柔 提交于 2019-11-26 09:57:11

问题


I wrote a function which works as expected but i don\'t understand 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

回答1:


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.



来源:https://stackoverflow.com/questions/4532144/output-is-truncated-with-signs-in-the-repl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!