将事实附加到现有的prolog文件中

我无法在现有的Prolog文件中插入事实,而不会覆盖原始内容。 假设我有一个文件test.pl:
:- dynamic born/2. 

born(john,london).
born(tim,manchester).
如果我在prolog中加载它,我断言更多的事实:
| ?- assert(born(laura,kent)).
yes
我知道我可以通过以下方式保存:
|?- tell('test.pl'),listing(born/2),told.
哪个有效,但test.pl现在只包含事实,而不是“: - dynamic born / 2”:
born(john,london).
born(tim,manchester).
born(laura,kent).
这是有问题的,因为如果我重新加载这个文件,我将无法再将任何事实插入test.pl,因为“: - dynamic born / 2”。不再存在了。 我读到某个地方,我能做到:
append('test.pl'),listing(born/2),told.
这应该只是附加到文件的末尾,但是,我收到以下错误:
! Existence error in user:append/1
! procedure user:append/1 does not exist
! goal:  user:append('test.pl')
顺便说一下,我正在使用Sicstus prolog。这有什么不同吗? 谢谢!     
已邀请:
毫不奇怪它只包含事实,因为这就是你告诉它要保存的全部内容。最简单的方法是使用
|?- tell('test.pl'), write(':- dynamic born/2.'), nl, listing(born/2), told.
或写一个小程序,这样做。根据您打算如何使用它,您可以考虑使用
save_program/1/2
restore/1
。 我无法帮助你
append/1
我害怕。     

要回复问题请先登录注册