This may be a rookie mistake, but I’m trying to solve this question:
Find the query to obtain the following answer using the findall predicate: Obtain a list of persons who work in a city other than the one where they live:
L = [suzy, paul].
This is the database:
city(ottawa,ontario).
city(toronto,ontario).
city(kingston,ontario).
city(gatineau,quebec).
city(montreal,quebec).
company(shopify,ottawa).
company(rossvideo,ottawa).
company(dium,gatineau).
company(uber,toronto).
company(deepmind,montreal).
company(google,toronto).
person(annie,gatineau).
person(paul,gatineau).
person(suzy,gatineau).
person(robert,gatineau).
person(tom,ottawa).
person(tim,kingston).
person(joe,montreal).
person(jane,ottawa).
person(marie,ottawa).
person(jack,toronto).
person(simon,toronto).
employee(annie,dium).
employee(tom,shopify).
employee(jane,shopify).
employee(marie,shopify).
employee(joe,deepmind).
employee(jack,google).
employee(simon,google).
employee(suzy,shopify).
employee(paul,rossvideo).
employee(marie,rossvideo).
employee(simon,uber).
Here is the predicate I tried to use to solve it:
worksIn(n, Y) :-
employee(n, Comp),
company(Comp, Y).
But it only returns false
. Does anyone know how to fix it?
2
Answers
when use variables, first letter must be uppercase.
I did:
so the final answer is:
I’m not sure if we can add the “worksIn” thing in or not