6
我寫了下面的簡單代碼,我期待當我寫'男性'時,這段代碼問我一次「是男性嗎?」如果我輸入'不',它會在屏幕上寫上「她是女性」。我想在序言中創建動態事實
male :- (print('is it male ? '),read(yes)) -> true; asserta(not(male)),female.
female:- not(male),print('she is female').
not(P) :- (call(P) -> fail ; true) .
但此代碼具有以下錯誤:
uncaught exception: error(permission_error(modify,static_procedure,not/1),asserta/1);
在SWI-序言的錯誤是:
ERROR: asserta/1: No permission to modify static_procedure `not/1'
not/1是一個預定義的靜態過程。考慮將名稱更改爲其他名稱。此外,你所做的並不完全正確。 – gusbro 2011-12-29 14:53:24