【发布时间】:2014-02-01 14:59:21
【问题描述】:
list_trawler([44|_],_).
list_trawler([H|T],[H|T1]) :-
list_trawler(T,T1).
这个谓词应该接受两个列表(比如“hello, world”和“hello”),如果第二个列表是第一个列表的第一个成员,则返回 true,直到有逗号([44])。然而,虽然它几乎可以工作,但它返回列表 AND _G395。我想摆脱_G395。
例如,
2 ?- list_trawler("hello, world",X).
X = [104, 101, 108, 108, 111|_G395]
3 ?- list_tralwer([43,78,12,90,44,12,67,98],X).
Correct to: "list_trawler([43,78,12,90,44,12,67,98],X)"? yes
X = [43, 78, 12, 90|_G30] ;
false.
谓词有什么问题?
【问题讨论】:
标签: prolog