使用REPL中的#-signs截断输出

时间:2010-12-25 23:35:16

标签: sml smlnj

我编写了一个按预期工作的函数,但我不明白为什么输出就是这样。

功能:

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;

测试:

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

输出:

val result = Or (And (Atom #,Not #),Or (Not #,Atom #)) : prop

1 个答案:

答案 0 :(得分:14)

这只是输出限制(是的,令人困惑) - 默认情况下,顶级(交互式shell)中的值打印输出的深度限制为相当小的数量(即5)。跳过的部分用#。

打印

您可以使用printDepth变量覆盖此深度 - 至少在SML-NJ中:

Control.Print.printDepth := 1024;

P.S。顺便说一句,这里不需要单独的do_xor和local函数 - 只需

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

会做的。