我写了以下简单的代码,我希望当我写“男性”时,这段代码会问我一次“它是男性吗?” 如果我输入“否”,它会在屏幕上写下“她是女性”。
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-prolog 中的错误是:
ERROR: asserta/1: No permission to modify static_procedure `not/1'