% Beginning with Prova 1.90.
% This example demonstrates the use of the new "update_fact" predicate.
% The nost general form is update_fact(fact1,fact2). This is equivalent to
% retractall(fact1), assert(fact2).
% A simpler form update_fact(fact1) is equivalent to retractall(fact1), assert(fact1).
% This built-in simplifies life in the case facts should be kept unique based
%   on a set of "keys", i.e., arguments that are non-variables in the first argument of update. 

:- eval(ex054()).

ex054() :-
	println(['---------']),
	assert( f(2,'b') ),
	update_fact( f(2,_) ),
	f(X,Y),
	println([f(X,Y)]).
ex054() :-
	println(['---------']),
	update_fact( f(2,'b') ),
	f(X,Y),
	println([f(X,Y)]).
ex054() :-
	println(['---------']),
	assert( f(2,'b') ),
	update_fact( f(2,'b') ),
	f(X,Y),
	println([f(X,Y)]).
ex054() :-
	println(['---------']),
	assert( f(2,'a') ),
	update_fact( f(2,_), f(2,'b') ),
	f(X,Y),
	println([f(X,Y)]).

% Prints:
% -----------
% ["f",2,Y]
% -----------
% ["f",2,Y]
% ["f",2,"b"]
% -----------
% ["f",2,Y]
% ["f",2,"b"]
% -----------
% ["f",2,"b"]
