以下是我使用的事实:
edge(route(fra), route(tog), walk).
edge(route(fra), route(105), walk).
edge(route(tog), route(togc), bus).
edge(route(togc), route(sub), walk).
edge(route(sub), route(ag), metro).
edge(route(ag), route(n), metro).
edge(route(n), route(a), metro).
edge(route(a), route(r), metro).
edge(route(re), route(m), metro).
edge(route(m), route(v), walk).
edge(route(105), route(t), bus).
edge(route(t), route(vi), metro).
edge(route(vi), route(m), metro).
edge(route(t), route(3), walk).
edge(route(3), route(m), bus).
谓词:
seek(route(v), _).
seek(route(R1), [[R2, How]|Res]) :-
edge(route(R1), route(R2), How),
seek(route(R2),Res).
当我询问查询?- seek(route(fra), X).
它应该在列表中返回R2
和How
,但在这种情况下Res
仍然未分配...我不知道如何绕过它来进行查询仅返回包含R2
的列表列表。任何帮助将不胜感激!