On Tuesday, August 27, 2002, at 01:31 PM, bruno patin wrote:
But now, as listing is not an iso-prolog directive how not to add the
same facts two times ?
Perhaps my_assertz:
my_assertz(Term) :-
(var(Term)
;
copy_term(Term, TermCopy),
my_clause(TermCopy) )
-> true
;
assertz(Term).
my_clause( Term ) :-
Term =.. [ (:-), Head, Body]
-> clause(Head, Body)
;
clause(Term, true).
This only assertz's Term if Term is ground (i.e. contains no unbound
variables) and is not unifiable with a clause already in the clause
database.