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.
当我在 GNU Prolog 和 SWI Prolog 上运行此代码时,它会正确计算差异列表中的元素数量。然而,Yap 进入了一个无限循环。
count(X-X1,0) :- unify_with_occurs_check(X,X1), !. count([H|T]-T1,N) :- count(T-T1,M), N is M+1. ?- count([1,2|A]-A,N).
为什么 Prolog 解释器(如 Yap)在询问此查询时不会终止?
Yap 5.1.3 中似乎有一个错误
较新的版本(用 Yap 6.2.2 测试)工作正常:
?- count([1,2|A]-A,N). N = 2