I have just started with Prolog and now I have my first problem, which I just can't solve:
I want to give the program 3 lists and as result I want to know if their sum is equal.
So something like this:
?- sum_equal([1,2,3],[4,1,1],[5,1,0]).
true
Until now I've got this:
partsum([],0).
partsum([Head|Tail],Solution) :-
partsum(Tail, Solution2),
Solution is Head+Solution2.
sum_equal([Head|Tail],[Head2|Tail2],[Head3|Tail3]):-
sum1=partsum([Head|Tail],sum1),
sum2=partsum([Head2|Tail2],sum2),
sum3=partsum([Head3|Tail3],sum3),
sum1=:=sum2,
sum1=:=sum3.
But now I get the following message:
evaluable 'sum1' does not exist.
Thanks for your help.