草莓序言集
我正在使用 Strawberry Prolog(我学校的计算机实验室拥有的)实现一个家谱,并且希望摆脱重复的答案。 findall 函数在 Strawberry Prolog 中工作,它将所有答案放在一个列表中,但我相信此编译器不存在 setof。我可以切换编译器或将 setof-function 添加到这个编译器中。我认为后者会是更好的学习体验,但我不知道从哪里开始。
有谁知道其他编译器中 setof 函数背后的代码以及如何将其转换为 Strawberry Prolog 吗?或者草莓 Prolog 中已经有类似 setof 的函数了吗?
谢谢。
I am implementing a family tree using Strawberry Prolog (what the computer labs have at my school) and would like get rid of the duplicate answers. The findall function works in Strawberry Prolog which put all the answers in a list, but I believe setof does not exist with this compiler. I could either switch compilers or add the setof-function to this one. I think the latter would be a better learning experience, but I have no idea where to start.
Does anyone happen to know the code behind the setof function in other compilers and how to convert this to Strawberry Prolog? Or is there a function similar to setof already in Strawberry Prolog?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地对 findall 的输出进行排序。当然,实现 setof 是一条更有价值的道路,但绝对不简单。这里来自 SWI-Prolog 的来源:
如你所见,基本的它总是 findall...
You can simply sort the output of findall. Of course implementing setof it's a much more rewarding path, but definitely not simple. Here source from SWI-Prolog:
As you can see, the basic it's always findall...