Good Day I am doing the problema of arithmetic in prolog and Yes its the dot Product I have Searched and found a mess of code that did not equal to what the book is asking me. Its a /3 so this is what i have so far but i need to sum the result of the product of both list. Any hint on what should be recommended to do?
dot([HD|TL],[HD2|TL2],Result):-
Mul is HD2 * HD,
dot(TL,TL2,Mul),
Result is Mul + Reuslt2.
dot([],[],0).
Your problems are that you're using
Mul
twice where you mean to use it once, andReuslt2
doesn't exist anywhere. Probably what you mean is:You use SWI-Prolog, so you can try :