Can I keep track of value I'm getting in an other variable while working in a recursion?
问题 predicates pathdistance(symbol,symbol,integer). solve(symbol,symbol,integer). clauses pathdistance(a,b,10). pathdistance(b,c,20). pathdistance(c,d,5). pathdistance(d,e,15). pathdistance(a,d,5). pathdistance(c,e,10). solve(X,Z,C):- pathdistance(X,Z,C). solve(X,Z,C):- pathdistance(X,Y,Cost), solve(Y,Z,C), Cost is Cost+C. goal solve(a,d,Cost). The answer I wanted for the Cost is the sum of all the C's (total distance) between a and d.The above code is not working, it is not allowing me to take a