Reputation: 647
I'm trying to write a predicate that increments a list item by a certain value. I wrote this one but it's not giving me the correct result:
%--Increments every single list item by a certain Value.
incList([],[],_).
incList([X | List], [X2 | List2],Value) :-
incList(List,List2),
X2 is X + Value.
It only increments the first one. Any solutions on how to solve this without changing the structure of the predicate? Thank you.
Upvotes: 0
Views: 1828
Reputation: 647
As joel76 mentioned I have a typo on line2 of second predicate. It should be incList(List,List2,Value)
not incList(List,List2)
.
Upvotes: 1