Dot product Prolog/3 need Hint for the SUM

前端 未结 2 1796
小蘑菇
小蘑菇 2021-01-21 15:09

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. I

2条回答
  •  故里飘歌
    2021-01-21 16:11

    You use SWI-Prolog, so you can try :

    :- use_module(library(lambda)).
    my_dot(L1,L2,R) :-
        foldl(\X^Y^Z^T^(T is X*Y + Z), L1,L2,0,R).
    

提交回复
热议问题