输出在 REPL 中被 # 符号截断
我编写了一个按预期工作的函数,但我不明白为什么输出是这样的。
功能:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是一个输出限制(是的,这很令人困惑) - 默认情况下,顶层(交互式 shell)中值打印输出的深度被限制为相当小的数字(即 5)。跳过的部分打印有#。
您可以使用 printDepth 变量覆盖此深度 - 至少在 SML-NJ 中:
PS 顺便说一句,您不需要单独的 do_xor 和本地函数 - 只
需要即可。
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:
P.S. By the way, you don't need a separate do_xor and local function here - just
will do.