3

如何转换这个

fact( [a,b,c], [d,e,f], ..., [p, q, r] )

这些元素的列表?

结果:

[[a,b,c], [d,e,f], ..., [p, q, r]]
4

2 回答 2

3
list_fact_args(Fact,List) :- Fact =.. [fact|List].

=.. is a handy predicate that transforms the predicate on the left to a list with predicate name as the first member and its arguments as the latter members. Or a list on a right to the predicate on the left. Here fact denotes that it lists only the predicates named 'fact'.

于 2014-02-09T22:01:01.680 回答
0

获取您的 Prolog 手册或教科书并查找 =.. / 2。

于 2014-02-09T21:49:37.887 回答