Get "variables" in Swi Prolog

1

I have this Knowledge Base

viveEn(dracula, castillo).
viveEn(godzilla, espacio).
viveEn(sullivan, espacio).
viveEn(mLegrand, tv).
maneja(godzilla, auto(4)).
maneja(barney, colectivo(fucsia,10,5)).
maneja(sullivan, nave([2,3,1]).

And I'm doing an exercise in which you are asked to create a rule where a monster can carry another monster but only if the first monster "drives" and both "live in" in the same place

Is not there a way in which, send the name of the monster and give me back where you live?

PD: at the time of doing it through queries if you can, but doing the rule no.

    
asked by Froilán Moya Robles 24.04.2017 в 08:11
source

1 answer

1

Something like that,

taxista(Taxista, Pasajero) :-
    maneja(Taxista, _),
    viveEn(Taxista, Donde), viveEn(Pasajero, Donde).

It is necessary to use an auxiliary variable, Donde , to make ' both live in the same place '.

    
answered by 24.04.2017 / 08:45
source