SWI-Promog:寻找一种在单独行中打印字典值的方法
我正在寻找一种打印一些 dictionary 以每种方式的值值在终端中的单独线上。
例如,如果我的
X = abc{a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10}.
输出本身是:
?- X = abc{a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10}.
X = abc{a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10}.
为了清楚起见,我现在的目的是获取以下输出:
X = abc{
a:1,
b:2,
c:3,
d:4,
e:5,
f:6,
g:7,
h:8,
i:9,
j:10
}.
很简单?
a:1
b:2
c:3
d:4
e:5
f:6
g:7
h:8
i:9
j:10
或者,它们的方法
I am searching a way to print some dictionary values in a way every value is on a separate line in the terminal.
For example if I have
X = abc{a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10}.
The output itself is:
?- X = abc{a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10}.
X = abc{a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10}.
For purpose of clarity my aim now is to get the following output:
X = abc{
a:1,
b:2,
c:3,
d:4,
e:5,
f:6,
g:7,
h:8,
i:9,
j:10
}.
or alternatively simple
a:1
b:2
c:3
d:4
e:5
f:6
g:7
h:8
i:9
j:10
Is their a way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以提供一个自定义
portray> portray/1
字典的钩子。例如:
这也将在嵌套术语上使用(尽管可以正确地将更多的护理添加到缩进的嵌套术语中)。示例输出:
如果钩子尚未启用以获取终端的答案(对我来说)您可能需要调整
wrath_write_options
标志。It is possible to provide a custom
portray/1
hook for dictionaries. As an example:This will also work on nested terms (though more care could be added to indent nested terms correctly). Example output:
If the
portray/1
hook is not already enabled for answers to the terminal (it was for me) you may need to adjust theanswer_write_options
flag.