Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Given the following Database.......

Status
Not open for further replies.

02091979

IS-IT--Management
Jul 10, 2002
1
IE
Hi I would appreciate some help with the following, thank you...
Given the following Database:
item_costs(hat,3).
item_costs(coat,5).
item_costs(jacket,7).
item_costs(shoes,3).
item_costs(trousers,6).
item_costs(scarf,4).
where item_costs(X,Y) is defined as item X costs Y euros.

1) write a rule costs_less(X,Y) which is true if item X costs less than item Y.
-What results would would your rule return in answer to the query:
costs_less(X,5).

2)write a rule costs_more(X,Y) which checks if item X costs more than item Y.
-What results would your rule return in answer to the following queries:
costs_more(scarf,shoes).
costs_more(Jacket,scarf).
costs_more(X,Y).
 

Code:
costs_less(X, Y) :- item_costs(X, P), item_costs(Y, Q), P < Q.

etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top