Jes*_*erg 11
假设这是你可以使用的SML/NJ printLength,printDepth以及来自Control.Print结构的朋友.
以下是Control.Print结构文档的片段:
printDepth
The depth of nesting of recursive data structure at which ellipsis begins.
printLength
The length of lists at which ellipsis begins.
stringDepth
The length of strings at which ellipsis begins.
Run Code Online (Sandbox Code Playgroud)
因此,例如,我们可以通过更改printLength引用来更改我们不会在REPL中显示的列表的元素数量
- Control.Print.printLength;
val it = ref 12 : int ref
- [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];
val it = [1,2,3,4,5,6,7,8,9,10,11,12,...] : int list
- Control.Print.printLength := 18;
val it = () : unit
- [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];
val it = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,...] : int list
- Control.Print.printLength := 100;
val it = () : unit
- [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];
val it = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] : int list
Run Code Online (Sandbox Code Playgroud)
请注意,对于字符串和数据结构,省略号将被写为散列"#".例如,使用以下字符串可以看到这一点.注意该val it = ...行末尾的"#" ,这是因为字符串的默认打印深度为70个字符:
- "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
val it = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusm#" : string
- Control.Print.stringDepth;
val it = ref 70 : int ref
Run Code Online (Sandbox Code Playgroud)
最后,举例说明如何在嵌套数据结构中看到这一点:
- Control.Print.printDepth;
val it = ref 5 : int ref
- SOME (SOME (SOME (SOME (SOME (SOME (SOME 42))))));
val it = SOME (SOME (SOME (SOME (SOME #))))
: int option option option option option option option
- Control.Print.printDepth := 10;
val it = () : unit
- SOME (SOME (SOME (SOME (SOME (SOME (SOME 42))))));
val it = SOME (SOME (SOME (SOME (SOME (SOME (SOME 42))))))
: int option option option option option option option
Run Code Online (Sandbox Code Playgroud)
这两个建议的解决方案无论多长时间都会打印整个列表.