<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
:- op(450,fx,[ins_key,del_key]).
:- op(900,xfy,[':=']).

init_keyappl :- 
	declare(key(counter/1,0)),
	ins(counter(1)).

bulk_ins(FromPred,ToPred) :-
	bulkins(FromPred,ToPred).

bulk_del(Pred) :-
	bulkdel(Pred).

% assign FromP to ToPred, note that ToPred should have been declared.
%
':='(ToPred,TestPred) :-
	ToPred =.. [Name|Args],
	Temp =.. [temp|Args],
	length(Args,NArgs),
	keyed(Name,NArgs,NKeys),
	NVal is NArgs-NKeys,
	createpreds(NVal,Vals),
	separate_key_val(Args,NKeys,Keys,_),
	append(Keys,Vals,DupArgs),
	DupPred =.. [temp|DupArgs],
	deleting(tr),
	copy((TestPred,not(DupPred)),Temp),
	retractall(OutPred),
	move(Temp,OutPred),
	inserting(tr).

incr_counter(N,Delta) :-
	retract(counter(N)),
	M is N + Delta,
	assert(counter(M)).

</pre></body></html>