From a37ae2f0170499be1a95031d24ff86aac5cf46f1 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Fri, 9 Jul 2021 20:09:22 +0000 Subject: Add asserta/1, assertz/1, retract/1, abolish/1 (and retract_one/1, which is retract/1 but doesn't backtrack) --- stdlib.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'stdlib.pl') diff --git a/stdlib.pl b/stdlib.pl index a972ae0..528781b 100644 --- a/stdlib.pl +++ b/stdlib.pl @@ -10,8 +10,7 @@ once(Goal) :- repeat :- true ; repeat. -% Control structures. -true. +% Control structures. If -> Then :- If, !, Then. @@ -150,7 +149,7 @@ E1 > E2 :- E2 < E1. -% Clause retrieval and information +% Clause retrieval and information and removal clause(Head, Body) :- clause(Head, Body, Clauses), @@ -160,6 +159,13 @@ current_predicate(PI) :- current_predicate(PI, Predicates), member(PI, Predicates). +retract(Clause) :- + copy_term(Clause, ClauseCopy), + retract_one(ClauseCopy), + ( Clause = ClauseCopy + ; retract(Clause) + ). + % Basic list predicates member(X, [X|_]). member(X, [_|Tail]) :- -- cgit v1.2.3