[item(name1,price1),..., item(namek,pricek)],
write program cost(L,Name,Price) which given a list L (as above) and Name, gives the price of that item.
b. Can this program be run backwards? That is, what happens when you provide the list L and Price, but not the Name?
c. Write a program like that in (a), except that it takes as an argument a list of names rather than a single name. That is, write a program listcost(L,Names,Price), where L is as above, Names is a list of names of items, and Price is the total cost of all of the items in Names. Can it be run backwards?
b. See if you can run this program backwards to integrate. (Feel free to make the constant term of the integral 0). If you cannot, what goes wrong? (You do not need to modify the program written in part a in a tricky way to make it run backwards. If it won't go backwards, just explain whycx!)
?- not(X=1),X=2.typically gives a different answer than the same query in reverse, i.e.
?- X=2, not(X=1).Run these programs and explain the different answers that you obtain. (See the solution to problem 31 on page 456 of the text for a hint.)