【发布时间】:2011-09-13 17:52:31
【问题描述】:
我在 prolog 中尝试了这个回文程序,逻辑有效,但写入操作无效。那么代码中的问题是什么?
palin(List1):- findrev(List1,[],List2), 比较(列表 1,列表 2)。
findrev([],List1,List1).
findrev([X|Tail],List1,List2):-
findrev(Tail,[X|List1],List2).
compare([],[]):-
write("\nList is Palindrome").
compare([X|List1],[X|List2]):-
compare(List1,List2).
compare([X|List1],[Y|List2]):-
write("\nList is not Palindrome").
【问题讨论】:
标签: prolog palindrome