Prolog/数据库修改
外观
< Prolog
此页面是存根。
来自 SWI 手册:[1]
asserta(+Term) Assert a fact or clause in the database. Term is asserted as the first fact or clause of the corresponding predicate. Equivalent to assert/1, but Term is asserted as first clause or fact of the predicate. assertz(+Term, -Reference) Equivalent to asserta/1, asserting the new clause as the last clause of the predicate. retract(+Term) When Term is an atom or a term it is unified with the first unifying fact or clause in the database. The fact or clause is removed from the database. retractall(+Head) All facts or clauses in the database for which the head unifies with Head are removed. If Head refers to a predicate that is not defined, it is implicitly created as a dynamic predicate. See also dynamic/1.35
示例
让我们从一个空数据库开始
?- human(john). ERROR: toplevel: Undefined procedure: human/1 (DWIM could not correct goal) ?- assert(human(john)). true. ?- human(X). X = john. ?-