Predicates
is_a(X,Y) X is a doctor/handyman
drives(X,Y) X drives Y
We are given that a doctor drives a sportscar and a handyman drives a 4WD
is_a(john,doctor).
is_a(david,handyman).
Now i want the code decide what kind of car john/david are driving....
I tried doing it...
drives(X,sportscar) :- is_a(X,doctor).
drives(Y,4WD) :- is_a(Y,handyman).
What am i doing wrong ??
?- drives(john,fourwd).
true .
?- drives(john,sportscar).
true .
?- drives(david,fourwd).
true .
?- drives(david,sportscar).
true .
Thanks....
3 replies to this topic
#1
Posted 30 September 2010 - 06:04 AM
|
|
|
#2
Posted 30 September 2010 - 06:44 AM
Quote
drives(Y,4WD) :- is_a(Y,handyman).
3 ?- drives(john,fourwd). false. 4 ?- drives(john,sportscar). true . 5 ?- drives(david,fourwd). true. 6 ?- drives(david,sportscar). false.
#3
Posted 30 September 2010 - 07:40 AM
Thanks for the help...
I have one more question.... Sorry if i'm bothering you too much....
In the same question....
I have another person called Jacob who drives the same type of car as david....
Thats alls that given... nad i'm really confused on what to do....
I have one more question.... Sorry if i'm bothering you too much....
In the same question....
I have another person called Jacob who drives the same type of car as david....
Thats alls that given... nad i'm really confused on what to do....
#4
Posted 30 September 2010 - 07:58 AM
actuall figured it out...
drives(barney,Y) :-
is_a(X,handyman),
drives(X,Y).
drives(barney,Y) :-
is_a(X,handyman),
drives(X,Y).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









