How to pass list's values one by one in another predicate prolog

Viewed 195

This is my prologdb file

trip_to_nation(X,Y,T):- % X is a city ,T is a list
      list_airport(Y,A),
      write(A),% [dublin,cork] list 
      all_trip(X,A,T). % here A is an atom and T is the list

I want to pass the list's value one by one to the all_trip such to get the data ,how it is possible?

Something like list[0],list[1] and get the data in the list .Thanks

1 Answers

Now T will have all the trips from X to elements of A.

maplist(all_trip(X), A, T).

If you want the trips as multiple solutions rather a list of them all, the following will work.

member(City, A), all_trip(X, City, T).
Related