% expensiveComp(+A,-Result)
% otherRule(+Arg1,Arg2+,-Result)
% r(+A,+B,C)
r(A,B,C) :-
expensiveComp(A,Result),
otherRule(Result,B,C).
If r
is called multiple times with the same value for A
will expensiveComp
necessarily be reevaluated each time r
is called, or are there circumstances under which Prolog would just bind a cached value to Result
?
Are some implementations of Prolog better at knowing when they don't need to reevaluate a rule?