Prolog - 如何仅断言/创建数据库一次 [英] Prolog - How to assert/make a database only once
本文介绍了Prolog - 如何仅断言/创建数据库一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
resultList(UsersQuery):-
question(X,H),
write(H),
myintersection(H,UsersQuery,Match,TotalQuestionKeywords),
Percent is Match/TotalQuestionKeywords*100,
write('Question: '),
write(X),nl,write('Quality: '), write(Percent),write('%'),nl,
/* please look at this part
Percent>=50,
assert(listofQuestions(Percent,Question)),
write(Percent),write(Question),nl,
fail.
resultList(_).
我想填充一个名为listofQuestions"的事实数据库.一切正常,但我断言的东西留在记忆中.所以,如果我再次运行我的程序,我会在问题列表"中添加同样的一堆事实.
I want to populate a fact database named 'listofQuestions'. Everything works fine, but the stuffs that I am asserting stays in the memory. So, if I run my program again, I get the same bunch of facts added to the 'listofQuestions'.
我只想拥有一组数据.
谢谢
推荐答案
也许在重新运行程序之前执行 retractall/1
.
Maybe do retractall/1
before you rerun your program.
这篇关于Prolog - 如何仅断言/创建数据库一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文