Hi,
I found some code for Matrix Multiplication in Prolog but I can't figure out what is wrong with it.
mmultiply([],_,[]).
mmultiply([V0|Rest], V1, [Result|Others]):-
mmultiply(Rest, V1, Others),
multiply(V1,V0,Result).
multiply([],_,[]).
multiply([V0|Rest], V1, [Result|Others]):-
multiply(Rest, V1, Others),
vmul(V0,V1,Result).
vmul([],[],0).
vmul([H1|T1], [H2|T2], Result):-
vmul(T1,T2, Newresult),
Result is H1*H2+Newresult.
When I call mmultiply([[1,2],[1,2]],X,[[1,2],[1,2]]). Prolog throws an error:
ERROR: is/2: Arguments are not sufficiently instantiated.
I'm new in Prolog and I don't know what is wrong.
Thanks for any suggestions.
I found some code for Matrix Multiplication in Prolog but I can't figure out what is wrong with it.
mmultiply([],_,[]).
mmultiply([V0|Rest], V1, [Result|Others]):-
mmultiply(Rest, V1, Others),
multiply(V1,V0,Result).
multiply([],_,[]).
multiply([V0|Rest], V1, [Result|Others]):-
multiply(Rest, V1, Others),
vmul(V0,V1,Result).
vmul([],[],0).
vmul([H1|T1], [H2|T2], Result):-
vmul(T1,T2, Newresult),
Result is H1*H2+Newresult.
When I call mmultiply([[1,2],[1,2]],X,[[1,2],[1,2]]). Prolog throws an error:
ERROR: is/2: Arguments are not sufficiently instantiated.
I'm new in Prolog and I don't know what is wrong.
Thanks for any suggestions.