prolog:将列表转换为字典?
I am searching some swi-prolog predicate:
list_to_dict(List, Dict) :- ??
Which is able to convert a list like
l = [a, b, c, d]
into a Prolog dict d
whose keys are equal to the list indexes starting at 1. In this example above d
is of form:
d = dict_label{1:a,2:b,3:c,4:d}
I would appreciate, if you can帮助我找到一些有关该问题的一般且希望简短的解决方案。
I am searching some swi-prolog predicate:
list_to_dict(List, Dict) :- ??
Which is able to convert a list like
l = [a, b, c, d]
into a Prolog dict d
whose keys are equal to the list indexes starting at 1. In this example above d
is of form:
d = dict_label{1:a,2:b,3:c,4:d}
I would appreciate, if you can help me to find some general and hopefully short solution of that problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下谓词:
示例:
You can use the following predicate:
Example: