Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从键盘输入(列表)中获取一个没有重复但不使用 XSB prolog 中的 inbuild setof(或任何其他 inbuild 函数)的列表。
我如何编写自己的 setof 函数?
输入和输出应如下所示:
|?-list([a,b,c,d,a,b,c,d,e,f],L). L=[a,b,c,d,e,f];
提前致谢。
使用 member/2 非常简单:只需使用递归列表/2 制作每个元素的副本,检查输入列表的头部,它还没有在目标列表中。可以由 member/2 执行检查,您需要自己编写... 整个程序应该是 4 行代码。