4
With the following facts,
x(p1,d1,c,d,e,f),
y(d1,d2,i,j,k,l),
z(d2,d3,o,p,q,r),
Thinking of them as points, I would like to know how I can go from x to z , making the input of P1 and D3.
I have, for example:
write('Partida: '),nl,
read(Partida_it),
write('Destino: '),nl,
read(Destino_it),
viagem(Partida_it,Destino_it,C,D,E,F),nl,
write(Partida_it),write('<-->'),write(Destino_it),nl,
write('Tipo: '),write(C),nl,
write('Hora de partida: '),write(D),nl,
write('Hora de chegada: '),write(E),nl,
write('Preco: '),write(F),nl,
fail,
In case such a journey already exists^
viagem(Partida_it,B,C,D,_,P1),nl,
viagem(B,Destino_it,F,_,E,P2),nl,
P is P1+P2,
write(Partida_it),write('<-->'),write(Destino_it),nl,
write('Tipo: '),write(C),write('e'),write(F),nl,
write('Hora de partida: '),write(D),nl,
write('Hora de chegada: '),write(E),nl,
write('Preco: '),write(P),nl,
fail.
I’ve been stuck with this problem for a few hours now.
Hello, welcome to Stackoverflow! Could you provide more details on your question? What kind of problem are you trying to solve? Where did you lock?
– Avelino
Hello, thank you, thank you! It is a travel platform between various transports, I have several trips in the database, for example trip(roma,Lisboa,aviao,12:00,15:00,300). travel(Lisboa,port,train,16:00,18:00,10). Giving input write('Departure: '),nl, read(Partida_it), write('Destination: '),nl, read(Destino_it). I want the program of an output of the necessary trips to arrive from Rome to Porto and the sum of prices
– newtopm