Writing predicates in prolog, data search

59 Views Asked by At

Write the predicate, reach(Departure, Arrivals) to find all points you can get into from the Departure point.

We have this facts:

trip(Id, From, To, Price)       
Id — flight number
From — departure point
To — Point of arrival
Price — price  


                                                                                                                                                                

trip(01, kuiv, odessa, 1500).
trip(02, kuiv, lviv, 700).
trip(03, uzhorod, krum, 6000).
trip(04, vunohradiv, odessa, 2540).
trip(05, ternopil, kuiv, 3800).
trip(06, zaporizhya, donetsk, 900).
trip(07, ternopil, mariupol, 7500).

For example ?- reach(kuiv([odessa, lviv])).

kuiv - we enter odessa, lviv - this is the result

1

There are 1 best solutions below

0
On

reach(Departure, Arrivals):- trip(_, From, To, _)

I only know that this is how you need to start, maybe someone more knowledgeable will help you