下面是打印列表是否为回文的给定程序,但我无法使用条件 L1=L & L1<>L 打印“列表为回文!” &“列表不是回文”,顺便说一句,我几乎尝试了所有在线可用的方法,但无济于事。
我尝试了 (if -> then ; else) & (if , then);(else , then) 等等,但都以失败告终。非常感谢您的帮助!
domains
ll=integer*
predicates
rev(ll,ll).
revl(ll,ll,ll).
clauses
rev(L1,L):-
revl(L1,[],L).
% I want to use if and else here to print If it is palindrome or not!
revl([],L,L).
revl([H|L1],L2,L3):-
revl(L1,[H|L2],L3).