简体   繁体   English

如何在另一个谓词序言中一个接一个地传递列表的值

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

This is my prologdb file这是我的 prologdb 文件

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?我想将列表的值一一传递给 all_trip 以获取数据,这怎么可能?

Something like list[0],list[1] and get the data in the list .Thanks类似于list[0],list[1]并获取列表中的数据。谢谢

Now T will have all the trips from X to elements of A.现在 T 将拥有从 X 到 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).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM