Reputation: 2181
I have 2 exception at point (THIS-RTE) and (Other-RTE) i can not manage to fix it can any1 give me a hint about what am i doing wrong, because I'm pretty sure i mess something up. Thanks
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).
Upvotes: 1
Views: 191
Reputation: 726479
Your syntax is a little off:
R is append(E,R1,R)
should be simply append(E,R1,R)
because you are passing R
R is [E|R1]
should go directly into the header of the ruleThe result should look like this:
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.
Upvotes: 3