Prolog 序言:如何创建谓词列表?

Prolog 序言:如何创建谓词列表?,prolog,Prolog,我想得出这样的结果 d_edge(a, b, 5). e_edge(a, c, 6). f_edge(b, c, 8). % I will have a list of rules for the graph point % from source to destination with weight. list2pair([T], [A,B], [(T,A,B)]). list2pair([T1|Tt], [A1,A2|T], Result) :- list2pair(Tt, [A

我想得出这样的结果

d_edge(a, b, 5).
e_edge(a, c, 6).
f_edge(b, c, 8).

% I will have a list of rules for the graph point 
% from source to destination with weight. 
list2pair([T], [A,B], [(T,A,B)]).
list2pair([T1|Tt], [A1,A2|T], Result) :-
   list2pair(Tt, [A1|T], R1),
   append([(T1,A1,A2)], R1, Result).
我的第一个参数将是名称列表
[d\u edge,f\u edge]
我的第二个参数是顶点列表
[a,b,c]

我的当前代码生成
[(d_边,a,b),(f_边,b,c)]

每当我尝试将谓词从
(T1,A1,A2)
更新为
T1(,A1,A2)
我得到一个错误,说它不是有效的谓词


我明白为什么我会出错。但是我找不到解决方法。

第一件事:
T1(,A1,A2)
在语法上是不正确的

下面是如何使用内置谓词继续操作:

请注意,以上仅“构造”了这些复合术语,它确实确保适当的事实
d_edge/3
f_edge/3
等确实存在。

W.r.t.a.k.a.“大学”。这曾经成功地应用于:
univ(名称(a1,a2),[[n,a,m,e],a1,a2])。
[d_edge(a,b), f_edge(b,c)]
list2pair([T], [A1,A2], [X]) :- X =.. [T,A1,A2]. list2pair([T1|Tt], [A1,A2|T], [X|Xs]) :- X =.. [T1,A1,A2], list2pair(Tt, [A2|T], Xs).
| ?- list2pair([d_edge,f_edge], [a,b,c], Xs).
Xs = [d_edge(a,b),f_edge(b,c)] ? ;               % expected result
no