如果我想使规则动态,所以我可以在加载数据库文件后使用assert,我该怎么做?我现在正在使用XSB Prolog,文件是这样的:
:- dynamic likes/2
likes(mary,tom)
Run Code Online (Sandbox Code Playgroud)
当我尝试使用XSB查阅该文件时,我收到一个错误:
? consult('D:\file.P).
not permitted to assert to static predicatelikes/2
forward continuation...blahblah
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
动态谓词的工作方式正如您所期望的那样,如果它不适合您,则会出现其他错误.
如果test.P看起来像这样:
:- dynamic likes/2.
likes(mary,tom).
Run Code Online (Sandbox Code Playgroud)
可以查阅它,然后可以断言更多喜欢/ 2个事实:
XSB Version 3.2 (Kopi Lewak) of March 15, 2009
[i686-pc-linux-gnu; mode: optimal; engine: slg-wam; scheduling: local; word size: 32]
| ?- consult('test.P').
[Compiling ./test]
[test compiled, cpu time used: 0.0440 seconds]
[test loaded]
yes
| ?- assert(likes(mary, bob)).
yes
| ?- likes(X,Y).
X = mary
Y = tom;
X = mary
Y = bob;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18840 次 |
| 最近记录: |