我有2个例外点( THIS-RTE )和(其他RTE )我无法设法修复它可以任意1给我一个关于什么是暗示的提示我做错了,因为我很确定我搞错了。感谢
decomp([],[],0,0).
decomp([E|T],R,P,I):-
0 is mod(E,2),
decomp(T,R1,P1,I),
R is [E|R1], %**(*THIS-RTE*)** ERROR: is/2: Type error: `[]' expected, found `[2|_G7167]' ("x" must hold one character)
P is 1 + P1.
decomp([E|T],R,P,I):-
not(0 is mod(E,2)),
decomp(T,R1,P,I1),
R is append(E,R1,R), %**(*Other-RTE*)** ERROR: d:/../../../../lab1a.pro:47: evaluable `append(_G5550,_G5551,_G5552)' does not exist, but my clause is right ther
I is 1 + I1.
append(E,[],[E]).
append(E,[A|St],[A|Et]):-
append(E,St,Et).
答案 0 :(得分:3)
你的语法有点不对:
R is append(E,R1,R)
应该只是append(E,R1,R)
,因为您正在传递R
R is [E|R1]
应直接进入规则标题结果应如下所示:
decomp([],[],0,0).
decomp([E|T], [E|R1], P, I):-
0 is E mod 2,
decomp(T,R1,P1,I),
P is 1 + P1.
decomp([E|T],R,P,I):-
1 is E mod 2,
decomp(T,R1,P,I1),
append(E,R1,R),
I is 1 + I1.