/* ********************************************************
	tr_appl4
************************************************************ */

:- op(900,xfy,[assign_to]).


% bulk insertion (always true, i.e. weak)
%
bulkins(FromFun,ToFun) :- 
	dynpred(ToFun),
	deleting(tr),
	copy(FromFun,ToFun),
	inserting(tr).

copy(FromFun,ToFun) :-
	call(FromFun), ins(ToFun), fail.
copy(_,_).


% bulk deletion (always true)
%
bulkdel(X) :-
	deleting(tr),
	retractall(X),
	inserting(tr).

% assignment
% For example,  assign q(X,Y) from p(X,Y)
% syntax:       assign_to(q, from([X,Y],p(X,Y))
%           or  assign_to(q, p(X,Y))
%
assign_to(OutPred,TestPred) :-
	OutPred =.. [_|Args],
	Temp =.. [temp|Args],
	dynpred(Temp),
	deleting(tr),
	copy(TestPred,Temp),
	retractall(OutPred),
	move(Temp,OutPred),
	inserting(tr).
	
move(From,ToPred) :-
	retract(From), assert(ToPred), fail.
move(_,_).
