% William Clocksin, Clause and Effect, Worksheet 7
% Inner Product of two Vectors Represented as Lists

ip([],[],0).
ip([A|As],[B|Bs],N) :- ip(As,Bs,N1), N is N1+(A*B).

% with an accumulator
ipA(A,B,N) :- dotaux(A,B,0,N).

dotaux([],[],V,V).
dotaux([A|As],[B|Bs],N,Z) :- N1 is N+(A*B), dotaux(As,Bs,N1,Z).
